跳到主要内容

计算字符串的 HMAC-SHA1 哈希值 (string.hmac_sha1)

声明

hexHash = string.hmac_sha1(data, key)

参数

  • data
    字符串型,用于计算哈希的数据内容
  • key
    字符串型,HMAC 算法使用的密钥

返回值

  • hexHash
    字符串型,返回 HMAC-SHA1 校验值的 16 进制小写文本

说明

使用 HMAC-SHA1 算法对任意字符串(或二进制数据)计算带密钥的哈希摘要

示例

local signature = string.hmac_sha1('hello world', 'secret')
sys.alert(signature) -- 输出 "03376ee7ad7bbfceee98660439a4d8b125122a5a"

:上述代码中使用了非本章函数 sys.alert