From a8e12b9630b7958d9f09021103d52bf4f32e1bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 19 Jan 2020 19:15:38 +0100 Subject: [PATCH] python3: pass bytes for hmac (#39092) --- welco/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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():