33
44import re
55from functools import wraps
6+ from itertools import chain
67from collections import OrderedDict
78import base64
89import hmac
@@ -25,7 +26,7 @@ def escapeVal(val):
2526 #for k,v in ordered_request.items():
2627 # signing_string.append(':'.join(k,escapeVal(v)))
2728
28- signing_string = ':' .join (map (escapeVal , map (str ,ordered_request .keys ()) + map (str ,ordered_request .values ())))
29+ signing_string = ':' .join (map (escapeVal , chain ( map (str ,ordered_request .keys ()), map (str ,ordered_request .values () ))))
2930
3031 return signing_string
3132
@@ -47,8 +48,7 @@ def escapeVal(val):
4748
4849 ordered_request = OrderedDict (sorted (dict_object .items (), key = lambda t : t [0 ]))
4950
50- signing_string = ':' .join (map (escapeVal , map (str ,ordered_request .keys ()) + map (str ,ordered_request .values ())))
51+ signing_string = ':' .join (map (escapeVal , chain ( map (str ,ordered_request .keys ()), map (str ,ordered_request .values () ))))
5152
52-
53- hm = hmac .new (hmac_key , signing_string , hashlib .sha256 )
53+ hm = hmac .new (hmac_key , signing_string .encode ('utf-8' ), hashlib .sha256 )
5454 return base64 .b64encode (hm .digest ())
0 commit comments