mirror of
https://github.com/solero/houdini.git
synced 2024-11-08 20:28:20 +00:00
Add support for hashing integers in the Crypto class
This commit is contained in:
parent
426311f856
commit
37e95138c9
@ -1,5 +1,5 @@
|
|||||||
import hashlib
|
from hashlib import md5
|
||||||
import secrets
|
from secrets import token_hex
|
||||||
|
|
||||||
|
|
||||||
class Crypto:
|
class Crypto:
|
||||||
@ -8,11 +8,13 @@ class Crypto:
|
|||||||
def hash(undigested):
|
def hash(undigested):
|
||||||
if type(undigested) == str:
|
if type(undigested) == str:
|
||||||
undigested = undigested.encode('utf-8')
|
undigested = undigested.encode('utf-8')
|
||||||
return hashlib.md5(undigested).hexdigest()
|
elif type(undigested) == int:
|
||||||
|
undigested = str(undigested).encode('utf-8')
|
||||||
|
return md5(undigested).hexdigest()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_random_key():
|
def generate_random_key():
|
||||||
return secrets.token_hex(8)
|
return token_hex(8)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def encrypt_password(password, digest=True):
|
def encrypt_password(password, digest=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user