From 63e04cb871f195aa01dac2fc3eb819bfa1db9b09 Mon Sep 17 00:00:00 2001 From: Ahmet Uludag Date: Tue, 19 May 2015 17:42:44 +0300 Subject: [PATCH] Update utils.py --- userena/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/userena/utils.py b/userena/utils.py index 30193bdb..7b69ab35 100644 --- a/userena/utils.py +++ b/userena/utils.py @@ -112,7 +112,10 @@ def generate_sha1(string, salt=None): if not salt: salt = sha_constructor(str(random.random()).encode('utf-8')).hexdigest()[:5] - salted_bytes = (salt.encode('utf-8') + unicode(string,'utf-8').encode('utf-8')) + if isinstance(string, str): + string = unicode(string, 'utf-8') + + salted_bytes = (salt.encode('utf-8') + string.encode('utf-8')) hash_ = sha_constructor(salted_bytes).hexdigest() return salt, hash_