summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-06-02 10:31:02 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-06-02 10:31:38 -0700
commit09d0568697cf5f82737816cf8041a6c270861a7d (patch)
treee68fa28b2c30e123c0dfba8a27c8fc5e1911cd27
parent590a41164e558fec8b54399d296c67dfffce6970 (diff)
Switched to using some constants the hmac module exposes.
-rw-r--r--django/utils/crypto.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/django/utils/crypto.py b/django/utils/crypto.py
index 5d0f381ffa..15db972560 100644
--- a/django/utils/crypto.py
+++ b/django/utils/crypto.py
@@ -28,10 +28,6 @@ from django.utils import six
from django.utils.six.moves import xrange
-_trans_5c = bytearray([(x ^ 0x5C) for x in xrange(256)])
-_trans_36 = bytearray([(x ^ 0x36) for x in xrange(256)])
-
-
def salted_hmac(key_salt, value, secret=None):
"""
Returns the HMAC-SHA1 of 'value', using a key generated from key_salt and a
@@ -130,9 +126,9 @@ def _fast_hmac(key, msg, digest):
if len(key) > dig1.block_size:
key = digest(key).digest()
key += b'\x00' * (dig1.block_size - len(key))
- dig1.update(key.translate(_trans_36))
+ dig1.update(key.translate(hmac.trans_36))
dig1.update(msg)
- dig2.update(key.translate(_trans_5c))
+ dig2.update(key.translate(hmac.trans_5C))
dig2.update(dig1.digest())
return dig2