TemplateSyntaxError at ...
Caught TypeError while rendering: character mapping must return integer, None or unicode
This can be fixed by simply coercing the key to string; though if the key had un-decodable unicode chars it would be another problem.
--- a/urlcrypt/lib.py
+++ b/urlcrypt/lib.py
@@ -52,7 +52,7 @@ deobfuscate = obfuscate
def encode_token(strings, secret_key_f):
secret_key = secret_key_f(*strings)
- signature = hmac.new(secret_key, pack(*strings), sha_hmac).hexdigest()
+ signature = hmac.new(str(secret_key), pack(*strings), sha_hmac).hexdigest()
packed_string = pack(signature, *strings)
return obfuscate(packed_string)