Mercurial > p > roundup > code
changeset 5454:fbbcbfc6dad0
fix encoding for hash functions
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Mon, 23 Jul 2018 21:40:31 +0100 |
| parents | 2b4f606d8e72 |
| children | 118f5ffd194e |
| files | roundup/password.py test/test_hyperdbvals.py |
| diffstat | 2 files changed, 5 insertions(+), 5 deletions(-) [+] |
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
--- a/test/test_hyperdbvals.py Mon Jul 23 21:39:46 2018 +0100 +++ b/test/test_hyperdbvals.py Mon Jul 23 21:40:31 2018 +0100 @@ -93,7 +93,7 @@ self.assert_(isinstance(val, password.Password)) val = self._test('password', '{crypt}a string') self.assert_(isinstance(val, password.Password)) - s = sha1('a string').hexdigest() + s = sha1(b'a string').hexdigest() val = self._test('password', '{SHA}'+s) self.assert_(isinstance(val, password.Password)) self.assertEqual(val, 'a string')
