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())