diff roundup/password.py @ 5454:fbbcbfc6dad0

fix encoding for hash functions
author Christof Meerwald <cmeerw@cmeerw.org>
date Mon, 23 Jul 2018 21:40:31 +0100
parents 1f1899658115
children 3d0f71775e42
line wrap: on
line diff
--- a/roundup/password.py	Mon Jul 23 21:39:46 2018 +0100
+++ b/roundup/password.py	Mon Jul 23 21:40:31 2018 +0100
@@ -108,7 +108,7 @@
     '''
     shaval = sha1(password)
     shaval.update( salt )
-    ssha_digest = b64encode( '{}{}'.format(shaval.digest(), salt) ).strip()
+    ssha_digest = b64encode( shaval.digest() + salt ).strip()
     return ssha_digest
 
 def pbkdf2(password, salt, rounds, keylen):
@@ -184,11 +184,11 @@
             # variable salt length
             salt_len = random.randrange(36, 52)
             salt = os.urandom(salt_len)
-        s = ssha(plaintext, salt)
+        s = ssha(s2b(plaintext), salt)
     elif scheme == 'SHA':
-        s = sha1(plaintext).hexdigest()
+        s = sha1(s2b(plaintext)).hexdigest()
     elif scheme == 'MD5':
-        s = md5(plaintext).hexdigest()
+        s = md5(s2b(plaintext)).hexdigest()
     elif scheme == 'crypt' and crypt is not None:
         if other is not None:
             salt = other

Roundup Issue Tracker: http://roundup-tracker.org/