-1
我试图得到一个字符串的哈希值的SHA256哈希:无法得到一个字符串
hs = hashlib.sha256(get_some_string()).hexdigest()
错误:
TypeError: Unicode-objects must be encoded before hashing
我试图得到一个字符串的哈希值的SHA256哈希:无法得到一个字符串
hs = hashlib.sha256(get_some_string()).hexdigest()
错误:
TypeError: Unicode-objects must be encoded before hashing
使用utf-8
编码:
hs = hashlib.sha256(get_some_string().encode('utf-8')).hexdigest()
欲了解更多信息,请阅读documentation。
http://stackoverflow.com/questions/18877589/python-unicode-utf-8可能会帮助你 – Tschallacka