HMAC Generator

Compute an HMAC signature for a message with SHA-1, SHA-256, SHA-384 or SHA-512 and a secret key given as UTF-8 text, hex or Base64, and get the result as hex, Base64 or Base64URL. Paste a signature you received, for example from a webhook header, and the tool tells you whether it matches using a constant-time byte comparison. Everything is computed with the Web Crypto API in your browser, so the key and the message are never uploaded.

How to use

  1. Choose the Algorithm (SHA-256 by default), the Key format (Text (UTF-8), Hex or Base64) and the Output format (Hex, Base64 or Base64URL).
  2. Enter your Secret key and paste the Message exactly as it was sent; the message is hashed as UTF-8 bytes, so an extra space or line break changes the result.
  3. Read the Signature, which updates as you type and shows its length in characters, and click Copy to copy it.
  4. To check a signature you received, paste it into Verify against expected signature and read Signature matches. or Signature does not match. Clear empties the key, the message and the expected signature.

Example

Input

Algorithm: SHA-256 · Key format: Text (UTF-8) · Output format: Hex
Secret key: my-shared-secret
Message: {"event":"ping"}

Output

Signature: e470ee69d7703829e26de63944852a7ade4e19f25569488a770f499e818a225c
64 characters

Output format Base64: 5HDuaddwOCnibeY5RIUqet5OGfJVaUiKdw9JnoGKIlw=

Frequently asked questions

How do I verify a GitHub or Stripe webhook signature?

Select SHA-256, enter the webhook secret as text and paste the raw request body exactly as received. GitHub sends the signature in the X-Hub-Signature-256 header as sha256=<hex>; paste only the hex part, because the sha256= prefix makes the value invalid hex. Stripe signs the timestamp, a dot and the body (t.body), so build the Message in that form and compare the result with the v1 value of the Stripe-Signature header.

Which key format should I choose?

Use Text (UTF-8) when the secret is a string that is used as is, which is the case for most webhook secrets. Choose Hex or Base64 when the key is raw bytes written in that encoding: hex may include spaces or a 0x prefix, and Base64 also accepts the URL-safe characters - and _ and missing = padding. An empty key cannot be used, because the Web Crypto API rejects zero-length HMAC keys.

Does the verification care about upper or lower case?

Not for hex. Both signatures are decoded to bytes in the selected Output format and compared byte by byte in constant time, so ABCD and abcd match. The expected signature must be in the same format as the Output format; otherwise you see a message such as Expected signature is not valid Hex.

Are my key and message sent to a server?

No. The HMAC is computed locally with your browser's Web Crypto API, and the key, the message and the signature are never uploaded or logged.

Related tools