Hmac算法:Keyed-Hashing for Message Authentication。它通过一个标准算法,在计算哈希的过程中,把key混入计算过程中。
import time
from hashlib import sha1
import hmac
import base64
username="xxxx"
apiKey="yyyy"
date=time.strftime("%a, %d %b %Y %H:%M:%S GMT",time.localtime())
my_sign = hmac.new(apiKey,date,sha1).digest()
password = base64.b64encode(my_sign)
print password
shell:
#!/bin/bash
username="XXXX"
apiKey="YYYY"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
转载于:https://www.cnblogs.com/hanjiajiejie/p/9050466.html
最后
以上就是心灵美裙子最近收集整理的关于python模块-hmac的全部内容,更多相关python模块-hmac内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复