summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-01-19 18:15:38 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-03-17 18:06:44 (GMT)
commita8e12b9630b7958d9f09021103d52bf4f32e1bff (patch)
treeeffab816d2c8f6bc67cfb191766214f0819afbf7
parent90c29f0fa0cce6606eba25c51e35cdd66c990d13 (diff)
downloadwelco-a8e12b9630b7958d9f09021103d52bf4f32e1bff.zip
welco-a8e12b9630b7958d9f09021103d52bf4f32e1bff.tar.gz
welco-a8e12b9630b7958d9f09021103d52bf4f32e1bff.tar.bz2
python3: pass bytes for hmac (#39092)
-rw-r--r--welco/utils.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/welco/utils.py b/welco/utils.py
index 22629b0..6f92139 100644
--- a/welco/utils.py
+++ b/welco/utils.py
@@ -26,6 +26,7 @@ import requests
from django.conf import settings
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseBadRequest
+from django.utils.encoding import smart_bytes
from django.utils.http import urlencode, quote
from django.utils.six.moves.urllib import parse as urlparse
@@ -54,7 +55,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 get_wcs_services():