HMAC Generator

Share:
Cybersecurity Tools

HMAC Generator

Generate HMAC signatures with SHA-1, SHA-256, SHA-384 or SHA-512. Output as hex, base64 or base64url. All computation in your browser — your secret never leaves this page.

By Last reviewed CRYPTO HMAC SHA-256
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

HMAC Generator Tool

Privacy: All HMAC computation happens inside your browser using the native SubtleCrypto API. Your secret key and message never leave this page. We do not log or proxy any inputs.

Line breaks are signed as LF (\n). A browser text box turns CRLF (\r\n) into LF, so a body sent with CRLF line endings will not give the provider's signature here.

📅 Research current as of 24 Nov 2026 · Sources: RFC 2104 §3 and RFC 4231 test vectors; RFC 6194 §3.3; NIST SP 800-131A Rev. 2 §9-10 and NIST's 15 Dec 2022 SHA-1 notice; GitHub, Slack and Stripe webhook-signing docs, read 24 Nov 2026
Standards, published formulas, and reference data are revised over time — check against a current authoritative source before relying on these figures.
Advertisement
After results · AD-W1 Responsive · Post-tool — peak engagement

How to use the HMAC generator

Paste your secret key

This is the shared secret between you and whoever you're signing data for — typically the value the API or webhook provider issued you.

Paste the message

The exact text you want to sign: a webhook payload or a provider's documented signing string. The page encodes it as UTF-8 and signs line breaks as LF.

Pick the algorithm

SHA-256 is the usual choice today. Use whatever the provider's documentation names: GitHub and Slack, for example, both sign with HMAC-SHA256. SHA-1 is offered for older systems that still require it.

Copy the signature

The signature is shown three ways: hex, base64 and base64url. GitHub and Slack both send hex, with a prefix (sha256= and v0= respectively); Shopify sends base64 with no prefix; JSON Web Tokens use base64url. Copy the encoding your destination expects.

Advertisement
After how-to · AD-W2 Responsive

HMAC — what it is, why APIs use it

HMAC (hash-based message authentication code) combines a secret key with a message to produce a short tag. Anyone who holds the same key can recompute the tag and check that the message has not been changed; without the key it cannot be forged. It was specified by Hugo Krawczyk, Mihir Bellare and Ran Canetti in RFC 2104, published in February 1997, and works with any hash function. This page computes it with the browser's built-in Web Crypto API.

Where you will meet it

Webhook signatures are the commonest use. GitHub signs each delivery with an HMAC hex digest of the payload and sends it in the X-Hub-Signature-256 header, prefixed sha256=. Slack builds a string from a version number, a timestamp and the request body, separated by colons, takes its HMAC-SHA256 hex digest and prefixes v0=. Stripe signs the timestamp, a full stop and the raw body with HMAC-SHA256 and sends the result as v1= in its Stripe-Signature header. Shopify computes HMAC-SHA256 over the raw request body with the app's client secret and sends it base64-encoded in the X-Shopify-Hmac-SHA256 header, with no prefix. AWS Signature Version 4 ends with HMAC-SHA256 too, but its key is derived from the secret access key by a chain of HMACs and is raw bytes, so this page, which takes the key as text, cannot produce a SigV4 signature. JSON Web Tokens signed with HS256 carry an HMAC-SHA256 tag.

"As of today, there is no indication that attacks on SHA-1 can be extended to HMAC-SHA-1." RFC 6194 (2011)

HMAC versus a plain hash

Hashing the secret and the message together, as in SHA-256(secret + message), is not a safe substitute. With hash functions like SHA-256, an attacker who sees one such tag can extend the message and compute a valid tag for the longer version without knowing the secret. HMAC's nested construction, with the key mixed in twice, was designed to avoid this.

Key length

RFC 2104 allows keys of any length. For a key shorter than the hash output it says "less than L bytes is strongly discouraged as it would decrease the security strength of the function", L being the output length, and that longer keys "are acceptable but the extra length would not significantly increase the function strength". In practice that means at least 32 random bytes for HMAC-SHA256 and 64 for HMAC-SHA512.

Verifying a signature

Recompute the HMAC over the exact bytes you received, before any JSON parsing changes them, and compare it with the signature using a constant-time comparison such as hash_equals in PHP, crypto.timingSafeEqual in Node.js or hmac.compare_digest in Python. An ordinary string comparison stops at the first difference, and the time it takes can leak how much of a forged signature was right. To check this page's output yourself, RFC 4231 publishes test vectors: key "Jefe" and message "what do ya want for nothing?" should give an HMAC-SHA256 beginning 5bdcc146.

RFC 2104, the providers that use it, and why HMAC-SHA1 still holds

01

HMAC was specified in RFC 2104 in February 1997 by Krawczyk, Bellare and Canetti.

02

RFC 2104 says keys shorter than the hash output are strongly discouraged; longer keys add little strength.

03

RFC 6194 (2011) found no indication that attacks on SHA-1 extend to HMAC-SHA-1.

04

GitHub signs webhooks with an HMAC hex digest in the X-Hub-Signature-256 header, prefixed sha256=.

05

Slack signs v0:timestamp:body with HMAC-SHA256 and sends the hex digest prefixed v0=.

06

AWS Signature Version 4 computes its final signature with HMAC-SHA256.

07

JSON Web Tokens signed with HS256 carry an HMAC-SHA256 tag, base64url-encoded.

08

RFC 4231 test vector: key "Jefe" and "what do ya want for nothing?" give an HMAC-SHA256 starting 5bdcc146.

09

Compare signatures with a constant-time function, not ==, so timing does not leak the answer.

10

This page uses the browser's Web Crypto API; the key and message never leave your device.

Frequently asked questions

A plain hash such as SHA-256 is a fingerprint anyone can compute and check. HMAC mixes in a secret key, so only someone with the key can produce or verify the tag. Webhooks and API signatures use HMAC; file checksums use plain hashes.
RFC 6194 (2011) found "no indication that attacks on SHA-1 can be extended to HMAC-SHA-1". The published attacks on SHA-1 find collisions, two messages with the same hash, and forging an HMAC tag without the key is a different problem. NIST SP 800-131A Rev. 2 (2019) lists HMAC generation with a key of at least 112 bits as acceptable with any approved hash, SHA-1 included, but NIST announced on 15 December 2022 that SHA-1 should be phased out by 31 December 2030. Use SHA-256 for anything new, and HMAC-SHA1 only where an existing system requires it.
Take the request body exactly as received, before any parsing. Compute the HMAC with the shared secret and the algorithm the provider names, encode it the way the provider does (GitHub and Slack use hex with a prefix, Shopify plain base64), and compare it with the received signature using a constant-time comparison. A match means the request came from someone holding the secret.
An ordinary comparison stops at the first byte that differs, so it returns slightly faster the less of a guess is right. An attacker who can measure that can work towards a valid signature. Use a constant-time comparison: hash_equals in PHP, crypto.timingSafeEqual in Node.js or hmac.compare_digest in Python.
HMAC is deterministic: the same key, message and hash always give the same tag, which is what makes verification possible. Slack and Stripe also put a timestamp in the signed string, so a receiver can reject an old request replayed later: Slack's example refuses one more than five minutes from local time, and Stripe's libraries default to a five-minute tolerance.
Stripe sends a Stripe-Signature header such as t=1798765432,v1=…, with a timestamp and one or more v1 signatures. Its webhooks documentation defines the signed string as the timestamp, a full stop and the unmodified request body, signed with HMAC-SHA256 and the endpoint's signing secret. To reproduce it here, enter the signing secret and put t, a full stop and the raw body in the message. The v1 values in Stripe's example header are 64 hexadecimal characters, so choose hex here. Then compare the result in constant time with every v1 value, ignore v0 (sandbox only) and any other scheme, and reject a timestamp outside your tolerance; Stripe's libraries default to five minutes.
GitHub uses an HMAC hex digest of the payload, sent in the X-Hub-Signature-256 header and always starting sha256=. Compute HMAC-SHA256 over the raw body with your webhook secret, choose hex output here, and compare it with the part after sha256=.
No. HMAC is fast by design, which is wrong for passwords. Use a password-hashing function such as Argon2id, scrypt or bcrypt, which are deliberately slow and salted.
Standard base64 (RFC 4648) uses + and / and pads with =. Those characters have special meanings in URLs, so base64url uses - and _ instead and usually drops the padding. JSON Web Tokens use base64url.
Yes, with the browser's Web Crypto API. Your key and message are not sent anywhere. For real production secrets, compute signatures on your own systems rather than in any web page.

Method & sources

How it computes

HMAC via the browser's Web Crypto API (importKey raw, sign) with SHA-1, SHA-256, SHA-384 or SHA-512. The key and the message are encoded as UTF-8, with line breaks in the message signed as LF, and the tag is shown as hex, base64 and base64url. An empty message is accepted and only the latest keystroke's result is shown.

What this tool implements

  • Output checked against RFC 4231 test case 2: key 'Jefe' and 'what do ya want for nothing?' give an HMAC-SHA256 beginning 5bdcc146. An empty message is a valid input and is signed.
  • RFC 2104 §3 on key length: a key of less than L bytes, L being the hash output length, is strongly discouraged; longer keys add little strength. The key is taken as UTF-8 text, so a secret issued as raw bytes (hex or base64) cannot be entered here.
  • HMAC-SHA-1: RFC 6194 §3.3 finds no indication that attacks on SHA-1 extend to HMAC-SHA-1. NIST SP 800-131A Rev. 2 (Table 9) lists HMAC generation with keys of at least 112 bits as acceptable, and NIST's notice of 15 December 2022 says SHA-1 should be phased out by 31 December 2030.
  • Webhook schemes from the providers' own documentation. GitHub: HMAC-SHA256 hex in X-Hub-Signature-256, prefixed sha256=. Slack: v0:timestamp:body, hex, prefixed v0=. Stripe: timestamp, a full stop and the raw body under HMAC-SHA256, compared in constant time with every v1 value, v0 ignored, default tolerance five minutes. Shopify (Shopify Dev Docs, "Verify webhook deliveries"): HMAC-SHA256 of the raw body with the app's client secret, base64 in X-Shopify-Hmac-SHA256. Slack and Stripe sign the timestamp so that a replayed request can be rejected.
  • A browser text box turns CRLF line endings into LF, so a body sent with CRLF will not reproduce the provider's signature here; the page says so beside the message field. AWS Signature Version 4 (AWS guide "Create a signed AWS API request", cited by title) signs with a key derived from the secret access key by a chain of HMACs; that key is binary, so a SigV4 signature cannot be made on this page.

Sources

Advertisement
Pre-footer · AD-W3 728 × 90