From eb286aa22f2a83a091b856ab2ecda1bded4203e3 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 6 Jun 2012 10:53:16 +0200 Subject: Delayed encoding of password and salt in password checking. Applied the rule that string encoding should happen as late as possible. This is also a preparation for Python 3 compatibility. --- django/utils/crypto.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'django/utils') diff --git a/django/utils/crypto.py b/django/utils/crypto.py index 9d6486c601..0fce06012b 100644 --- a/django/utils/crypto.py +++ b/django/utils/crypto.py @@ -22,6 +22,7 @@ except NotImplementedError: using_sysrandom = False from django.conf import settings +from django.utils.encoding import smart_str _trans_5c = b"".join([chr(x ^ 0x5C) for x in xrange(256)]) @@ -137,6 +138,8 @@ def pbkdf2(password, salt, iterations, dklen=0, digest=None): assert iterations > 0 if not digest: digest = hashlib.sha256 + password = smart_str(password) + salt = smart_str(salt) hlen = digest().digest_size if not dklen: dklen = hlen -- cgit v1.3