HMAC Generator HMAC 签名工具
输入密钥(Key)与消息(Message),选择算法(如 HMAC-SHA256),生成常用签名(Hex/Base64),适合做 API 签名、Webhook 校验、消息完整性验证。
Enter a key and a message, pick an algorithm (e.g., HMAC-SHA256), and get signatures in Hex/Base64 for API signing & verification.
1. 输入参数 · Inputs
3. 使用说明 · Notes
-
HMAC 是什么? · What is HMAC?
HMAC(Hash-based Message Authentication Code)是“带密钥的哈希认证码”。它把密钥 Key与消息 Message结合起来计算,输出固定长度的签名。
HMAC combines a secret key and a message to produce a fixed-length signature for integrity & authenticity checks. -
HMAC ≠ 单纯 Hash · HMAC is not just a hash
单纯 SHA-256(message) 没有密钥,任何人都能算;HMAC-SHA256(key, message) 需要同一把 key 才能生成/验证。
SHA-256(message) is public; anyone can compute it. HMAC requires the shared secret key to sign/verify. -
为什么你算出来不一样?最常见原因 · Why does my result differ?
1)服务端要求把参数按字典序排序;2)要求 URL 编码(或要求不编码);3)原文末尾是否带换行;4)JSON 序列化规则不同(空格/缩进/字段顺序);5)Key 实际是 Hex/Base64 字节而不是“文本”。
Common causes: canonicalization differences (param sorting), URL encoding rules, trailing newline, JSON serialization differences, or the key being bytes (Hex/Base64) rather than plain text. -
怎么用于 Webhook 校验? · How to verify a webhook?
通常流程:服务端发送 payload + signature;你用相同的 secret 对 payload 计算 HMAC,再与 signature 对比。注意对比时建议使用“常数时间比较”(防侧信道)。
Typical flow: provider sends payload + signature; you compute HMAC with the same secret and compare. Use constant-time comparison to reduce timing attacks. -
安全建议 · Security tips
不要用真实生产密钥做在线测试;优先在本地离线环境校验。若必须粘贴,请确认页面无网络请求、无第三方脚本。
Avoid testing production secrets online. Prefer offline/local verification. If you must paste, ensure the page has no network calls and no third-party scripts. -
兼容性 · Compatibility
本工具使用浏览器 Web Crypto API(crypto.subtle)。现代 Chrome/Edge/Firefox 基本可用;若在老旧浏览器/某些 WebView 不支持,会提示错误。
This tool uses Web Crypto API (crypto.subtle). Modern browsers should work; older browsers/WebViews may not.
免责声明:本工具仅用于学习与调试,结果取决于你输入的“签名原文”与服务端规则是否一致,不构成任何安全或加密方案建议。
Disclaimer: For learning/debugging only. Results depend on whether your canonical string matches the server’s spec. Not a security design recommendation.
