Make s_utils.signature work in python3
This function will need to be extended to work with more character sets if utf-8 is not enough.
This commit is contained in:
@@ -372,8 +372,16 @@ def factory(klass, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def signature(secret, parts):
|
def signature(secret, parts):
|
||||||
"""Generates a signature.
|
"""Generates a signature. All strings are assumed to be utf-8
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(secret, six.binary_type):
|
||||||
|
secret = secret.encode('utf-8')
|
||||||
|
newparts = []
|
||||||
|
for part in parts:
|
||||||
|
if not isinstance(part, six.binary_type):
|
||||||
|
part = part.encode('utf-8')
|
||||||
|
newparts.append(part)
|
||||||
|
parts = newparts
|
||||||
if sys.version_info >= (2, 5):
|
if sys.version_info >= (2, 5):
|
||||||
csum = hmac.new(secret, digestmod=hashlib.sha1)
|
csum = hmac.new(secret, digestmod=hashlib.sha1)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user