crypto.hmac_sha256
crypto.hmac_sha256
功能
使用密钥生成当前文本的 HMAC-SHA256 签名。
语法
crypto(text).hmac_sha256(key)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| key | String | 是 | 无 | HMAC 密钥。 |
返回值
| 类型 | 说明 |
|---|---|
| String | HMAC-SHA256 小写十六进制签名。 |
代码示例
result = crypto('payload').hmac_sha256('secret') // 输出:b82fcb791acec57859b989b430a826488ce2e479fdf92326bd0a2e8375a42ba4 print result
注意事项
- 文本和密钥都按 UTF-8 字节参与计算。