PythonStudy——hmac 模块

import hmac
# hmac.new(arg)  # 必须提供一个参数
cipher = hmac.new('加密的数据'.encode('utf-8'))
print(cipher.hexdigest())

cipher = hmac.new('前盐'.encode('utf-8'))
cipher.update('加密的数据'.encode('utf-8'))
print(cipher.hexdigest())

cipher = hmac.new('加密的数据'.encode('utf-8'))
cipher.update('后盐'.encode('utf-8'))
print(cipher.hexdigest())

cipher = hmac.new('前盐'.encode('utf-8'))
cipher.update('加密的数据'.encode('utf-8'))
cipher.update('后盐'.encode('utf-8'))
print(cipher.hexdigest())

 

posted @ 2019-05-08 20:27  挺锅锅  阅读(83)  评论(0编辑  收藏  举报