1.首先双方基本算法需要一致,这里都以sha1为基本规则
2.python部分,如果是使用digest()输出,php部分则一定要使用原始二进制数据输出。
python: hmac.new('test', 'test', hashlib.sha1).digest()
php: hash_hmac('sha1','test','test',true);
3.python部分如果是使用hexdigest()输出,则php部分去掉最后一个raw数据参数即可匹配。
python: hmac.new('test', 'test', hashlib.sha1).hexdigest()
php: hash_hmac('sha1','test','test');
---------------------
作者:Orz___Li
来源:CSDN
原文:https://blog.csdn.net/ligongxiang123/article/details/76590196
版权声明:本文为博主原创文章,转载请附上博文链接!
python hmac
最新推荐文章于 2024-06-18 16:51:33 发布