from hashlib import sha256 import hmac def get_sign(data, key): key = key.encode('utf-8') message = data.encode('utf-8') sign = base64.b64encode(hmac.new(key, message, digestmod=sha256).digest()) sign = str(sign, 'utf-8') print(sign) return sign
用python实现HmacSHA256加密算法介绍到这里,更多Python学习请参考编程字典Python教程 和问答部分,谢谢大家对编程字典的支持。
原文链接:https://www.cnblogs.com/pythonywy/p/13993930.html