diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-21 10:00:10 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-07 12:00:22 +0200 |
| commit | c5ef65bcf324f4c90b53be90f4aec069a68e8c59 (patch) | |
| tree | bb9a4988fbae4e7366cc578ca845c49003cdcd64 /django/utils/crypto.py | |
| parent | ee191715eae73362768184aa95206cf61bac5d38 (diff) | |
[py3] Ported django.utils.encoding.
* Renamed smart_unicode to smart_text (but kept the old name under
Python 2 for backwards compatibility).
* Renamed smart_str to smart_bytes.
* Re-introduced smart_str as an alias for smart_text under Python 3
and smart_bytes under Python 2 (which is backwards compatible).
Thus smart_str always returns a str objects.
* Used the new smart_str in a few places where both Python 2 and 3
want a str.
Diffstat (limited to 'django/utils/crypto.py')
| -rw-r--r-- | django/utils/crypto.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/django/utils/crypto.py b/django/utils/crypto.py index 9d46bdd793..1edbb43eb3 100644 --- a/django/utils/crypto.py +++ b/django/utils/crypto.py @@ -23,7 +23,7 @@ except NotImplementedError: using_sysrandom = False from django.conf import settings -from django.utils.encoding import smart_str +from django.utils.encoding import smart_bytes from django.utils.six.moves import xrange @@ -115,7 +115,7 @@ def _fast_hmac(key, msg, digest): A trimmed down version of Python's HMAC implementation """ dig1, dig2 = digest(), digest() - key = smart_str(key) + key = smart_bytes(key) if len(key) > dig1.block_size: key = digest(key).digest() key += chr(0) * (dig1.block_size - len(key)) @@ -141,8 +141,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) + password = smart_bytes(password) + salt = smart_bytes(salt) hlen = digest().digest_size if not dklen: dklen = hlen |
