From 37e95138c9c96142f719b663cc6e959d4300d3bb Mon Sep 17 00:00:00 2001 From: Daan <24899039+Zaseth@users.noreply.github.com> Date: Wed, 2 Oct 2019 11:13:32 +0200 Subject: [PATCH] Add support for hashing integers in the Crypto class --- houdini/crypto.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/houdini/crypto.py b/houdini/crypto.py index c8217ed..7f7318b 100644 --- a/houdini/crypto.py +++ b/houdini/crypto.py @@ -1,5 +1,5 @@ -import hashlib -import secrets +from hashlib import md5 +from secrets import token_hex class Crypto: @@ -8,11 +8,13 @@ class Crypto: def hash(undigested): if type(undigested) == str: 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 def generate_random_key(): - return secrets.token_hex(8) + return token_hex(8) @staticmethod def encrypt_password(password, digest=True):