python3: use smart bytes for signatures
This commit is contained in:
parent
b26cc32c59
commit
ae15cab91e
|
@ -21,6 +21,7 @@ import hashlib
|
|||
import random
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils.http import quote, urlencode
|
||||
from django.utils.six.moves.urllib.parse import urlparse, urlunparse, parse_qs
|
||||
|
||||
|
@ -51,7 +52,7 @@ def sign_query(query, key, algo='sha256', timestamp=None, nonce=None):
|
|||
|
||||
def sign_string(s, key, algo='sha256', timedelta=30):
|
||||
digestmod = getattr(hashlib, algo)
|
||||
hash = hmac.HMAC(str(key), digestmod=digestmod, msg=s)
|
||||
hash = hmac.HMAC(smart_bytes(key), digestmod=digestmod, msg=smart_bytes(s))
|
||||
return hash.digest()
|
||||
|
||||
def check_request_signature(django_request, keys=[]):
|
||||
|
|
Loading…
Reference in New Issue