Zdalne-systemy-z-kit-uVPN/utils.py
2023-04-13 13:12:08 +02:00

15 lines
425 B
Python

import hashlib
import secrets
import string
import random
def generate_random_string(length):
letters = string.ascii_letters + string.digits + string.punctuation
random_string = ''.join(random.choice(letters) for i in range(length))
return random_string
def hash_password(password):
return hashlib.sha512(password.encode('utf-8')).hexdigest()
def generate_auth_token():
return secrets.token_urlsafe(32)