# Free Online HMAC Generator and Verifier

> Generate HMAC-SHA256, SHA-384 and SHA-512 signatures with a secret key. Runs in your browser, so the signing key stays local. Free online.

Canonical: https://stayslocal.app/dev/hmac-generator
Last updated: 2026-08-16

HMAC proves a message came from someone holding a shared secret and has not been changed on the way. It is what sits behind the signature header on a Stripe or GitHub webhook — and it is exactly the kind of thing you should never compute on a site that could keep your key.

## RFC 2104, and why it is not just hash(key + message)

HMAC is defined in RFC 2104 as H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ message)) — two nested hashes with the key mixed in twice using different pads. That construction exists because the obvious approach, hashing the key concatenated with the message, is vulnerable to length-extension against Merkle-Damgård hashes like SHA-2. The output is the same length as the underlying hash: 32 bytes for HMAC-SHA256, 64 for HMAC-SHA512.

Fields:
- Key: Any length. Keys longer than the block size are hashed first; shorter ones are zero-padded, both by the spec.
- Algorithm: HMAC-SHA256, SHA-384 or SHA-512, via WebCrypto. The digest length follows the hash.
- Message bytes: Signed as UTF-8. Webhook verification must use the exact raw request body — re-serialised JSON produces a different signature.
- Output: Hex or Base64. Providers differ: Stripe sends hex, several others send Base64, and comparing across encodings always fails.
- Comparison: Verify with a constant-time compare such as crypto.timingSafeEqual. A plain === leaks how much of the signature matched.

## How to generate an HMAC signature online

1. Enter the secret key — The signing secret from the provider's dashboard, or your own.
2. Paste the message — For a webhook, the raw body exactly as received — bytes, not reformatted JSON.
3. Compare the digest — Match it against the provider's header, in the same encoding.

## Where HMAC is the mechanism

- Reproducing a Stripe or GitHub webhook signature to debug a rejected delivery.
- Signing an internal API request between two services that share a secret.
- Producing a tamper-evident token for a short-lived download URL.
- Checking an implementation against a known test vector.

## Questions

**Is it safe to paste my signing secret here?**

The key is used by WebCrypto inside this browser tab and appears in no network request, so it does not reach us or anyone else. It is still a production secret: use a test key where you can, and rotate anything you have pasted into a tool you have not verified.

**Why does my webhook signature never match?**

Almost always the message bytes. Frameworks parse and re-serialise the JSON body before you see it, which changes whitespace and key order and therefore the HMAC. You must sign the raw body, and include the timestamp prefix if the provider specifies one.

**Is HMAC the same as a digital signature?**

No. HMAC uses one shared secret, so anyone who can verify can also forge. A digital signature uses a private key to sign and a public key to verify, which is what gives non-repudiation. HMAC does not.

**Why does constant-time comparison matter?**

A normal string comparison returns as soon as it finds a difference, so the time it takes reveals how many leading characters were right. Over enough attempts that recovers a valid signature byte by byte. Verify with a constant-time function.

## Related

- [SHA Hash](https://stayslocal.app/dev/sha256-hash-generator): SHA-256, SHA-384 and SHA-512 of text
- [JWT Decoder](https://stayslocal.app/dev/jwt-decoder): Decode a JSON Web Token's claims
- [Developer Tools](https://stayslocal.app/dev): every tool in this family
