Simplified crypto.py

Use secrets.token_hex for generating random keys.
This commit is contained in:
Daan
2019-09-27 20:00:53 +02:00
committed by GitHub
parent 96109b5b3c
commit fb20faee2a

View File

@@ -1,8 +1,5 @@
import hashlib
import secrets
import string
_alphabet = string.ascii_letters + string.digits
class Crypto:
@@ -15,7 +12,7 @@ class Crypto:
@staticmethod
def generate_random_key():
return ''.join(secrets.choice(_alphabet) for _ in range(16))
return secrets.token_hex(8)
@staticmethod
def encrypt_password(password, digest=True):