summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-06-06 10:53:16 +0200
committerClaude Paroz <claude@2xlibre.net>2012-06-06 10:53:16 +0200
commiteb286aa22f2a83a091b856ab2ecda1bded4203e3 (patch)
tree186f9d5954988ea447852c04af77caac279e78ed /django/utils
parent9c096ab981d57123a0774f9ddf229084e0bb54a1 (diff)
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.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/crypto.py3
1 files changed, 3 insertions, 0 deletions
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