跳到主要内容
uencoder

生成 an HMAC and verify a message's authenticity

计算 a keyed-hash (HMAC) of a message to prove it came from someone sharing the secret, then verify a received HMAC.

  1. 1

    HMAC combines secret 键具有 hash 函数到 生成 tag 该 proves 两者完整性和 authenticity. Only 某人具有相同键 能够生成或 验证 tag. 它是 used 在 webhooks, API 签名, 和 JWT HS256.

  2. 2
    HMAC 生成器 →

    Enter 消息和 secret 键, 选择 hash algorithm (SHA-256 recommended). tool 输出 HMAC tag as hex 或 Base64.

  3. 3

    Use sign-and-验证链接: sign 消息, 然后验证它 针对正确和 tampered 消息到 see 通过/失败在 one 运行.

  4. 4

    当 verifying received webhook, recompute HMAC 遍历 raw 请求主体具有你的 shared secret 和比较在 常量时间. 从不 use == 哪个是 vulnerable 到 timing attacks.

常见问题

HMAC vs digital 签名 — what's 差集?
HMAC 我们 shared secret 键 — 两者 sender 和 receiver 能够 sign, 所以它 proves authenticity 仅到 parties 谁已经有 键. Digital signatures use asymmetric 关键 — 仅私有键 holder 能够 sign, 任何人具有公共键 能够验证.
哪个 hash algorithm 应该 I use 为 HMAC?
SHA-256 是现代默认. SHA-1 是已弃用但 HMAC-SHA1 是仍然 considered 安全 (HMAC's construction protects 针对 SHA-1's collision weakness). Avoid MD5-based HMAC 为新 systems.

解决此任务的工作流

相关工具