python实现HmacSHA256加密算法

python实现HmacSHA256加密算法[Python基础]

一.代码

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
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » python实现HmacSHA256加密算法