Skip to content
Accessibility
Theme
Text size
High contrast
Limit animations
Readable fontAtkinson Hyperlegible
Increased text spacing
Underline links
Always show focus

Runs in your browser — nothing you paste is uploaded.

HMAC Generator

Compute an HMAC signature from a message and a secret key. SHA-1, SHA-256, SHA-384 or SHA-512, via the Web Crypto API. Runs in your browser.


      

What it does

HMAC (Hash-based Message Authentication Code) combines a message with a secret key and a hash function to produce a short tag. Anyone who holds the same key can recompute the tag and confirm the message is authentic and unmodified; anyone without the key cannot forge a valid tag. It is the mechanism behind most webhook signatures (Stripe, GitHub, Slack and others). Pick the hash, type the key and the message, and you get the signature as a lowercase hex digest, computed with the browser's native Web Crypto API.

Choosing the hash

The digest length follows the hash: SHA-1 is 40 hex chars, SHA-256 64, SHA-384 96 and SHA-512 128. HMAC-SHA256 is the sensible default and what most webhook providers use. HMAC-SHA1 is still cryptographically sound for authentication (the collision attacks on plain SHA-1 don't break HMAC), but new designs should prefer SHA-256 or stronger.

Gotchas

  • Encoding matters. This tool treats both key and message as UTF-8 text. If a provider's key is hex or base64, decode it to raw bytes first (e.g. with Base64) — signing the literal hex string gives a different, wrong result.
  • Exact bytes matter. A trailing newline, different line endings (\n vs \r\n), or a reordered JSON body all change the signature. Sign the raw request body exactly as sent, not a re-serialised copy.
  • Hex vs base64 output. Many APIs send the signature base64-encoded or prefixed (e.g. sha256=…). This tool outputs hex; convert if you are comparing against such a header.
  • When verifying, compare with a constant-time check on the server to avoid timing leaks — a plain string == can be attacked.

Worked example

To verify a GitHub webhook, GitHub signs the raw JSON payload with your webhook secret using HMAC-SHA256 and sends it as X-Hub-Signature-256: sha256=<hex>. Paste the secret as the key, the exact payload as the message, pick SHA-256, and the hex digest here should match the part after sha256=. HMAC differs from a plain hash precisely because of that secret key — without it, anyone could fake the tag.

Privacy

The key and message stay in your browser and are never uploaded.

Frequently asked questions

What's the difference between HMAC and a plain hash?

A plain hash like SHA-256 can be computed by anyone, so it only proves integrity, not origin. HMAC mixes in a secret key, so a matching tag also proves the message came from someone who knows the key. That's why webhooks use HMAC rather than a bare hash.

My signature doesn't match the provider's — why?

Almost always an encoding mismatch. Check that the key is supplied in the right form (decode a hex or base64 key to raw bytes first), that you're signing the exact raw body including whitespace and line endings, and that you're comparing the same encoding — this tool outputs hex, while many APIs use base64 or a sha256= prefix.

Is HMAC-SHA1 still safe to use?

For message authentication, yes — the known SHA-1 collision attacks don't translate into HMAC forgeries. Still, prefer HMAC-SHA256 or stronger for new systems, since it costs nothing extra and keeps you clear of deprecated primitives.

Related tools