Zdalne-systemy-z-kit-uVPN/utils.py

15 lines
425 B
Python
Raw Normal View History

2023-04-13 09:52:51 +00:00
import hashlib
import secrets
2023-04-13 11:12:08 +00:00
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
2023-04-13 09:52:51 +00:00
def hash_password(password):
return hashlib.sha512(password.encode('utf-8')).hexdigest()
def generate_auth_token():
return secrets.token_urlsafe(32)