HMAC Generator
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.
HMAC Generator Tool
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.
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.
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
HMAC was specified in RFC 2104 in February 1997 by Krawczyk, Bellare and Canetti.
RFC 2104 says keys shorter than the hash output are strongly discouraged; longer keys add little strength.
RFC 6194 (2011) found no indication that attacks on SHA-1 extend to HMAC-SHA-1.
GitHub signs webhooks with an HMAC hex digest in the X-Hub-Signature-256 header, prefixed sha256=.
Slack signs v0:timestamp:body with HMAC-SHA256 and sends the hex digest prefixed v0=.
AWS Signature Version 4 computes its final signature with HMAC-SHA256.
JSON Web Tokens signed with HS256 carry an HMAC-SHA256 tag, base64url-encoded.
RFC 4231 test vector: key "Jefe" and "what do ya want for nothing?" give an HMAC-SHA256 starting 5bdcc146.
Compare signatures with a constant-time function, not ==, so timing does not leak the answer.
This page uses the browser's Web Crypto API; the key and message never leave your device.
Frequently asked questions
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
- Krawczyk H, Bellare M, Canetti R. RFC 2104: HMAC: Keyed-Hashing for Message Authentication. IETF; February 1997. https://www.rfc-editor.org/rfc/rfc2104
- Nystrom M. RFC 4231: Identifiers and Test Vectors for HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512. IETF; December 2005. https://www.rfc-editor.org/rfc/rfc4231
- Polk T, Chen L, Turner S, Hoffman P. RFC 6194: Security Considerations for the SHA-0 and SHA-1 Message-Digest Algorithms. IETF; March 2011. https://www.rfc-editor.org/rfc/rfc6194
- Barker E, Roginsky A. NIST SP 800-131A Rev. 2: Transitioning the Use of Cryptographic Algorithms and Key Lengths. NIST; March 2019. https://doi.org/10.6028/NIST.SP.800-131Ar2
- NIST. NIST Retires SHA-1 Cryptographic Algorithm. 15 December 2022. https://www.nist.gov/news-events/news/2022/12/nist-retires-sha-1-…
- GitHub Docs. Validating webhook deliveries. https://docs.github.com/en/webhooks/using-webhooks/validating-web…
- Slack Developer Docs. Verifying requests from Slack. https://docs.slack.dev/authentication/verifying-requests-from-slack/
- Stripe Docs. Receive Stripe events in your webhook endpoint (Verify webhook signatures manually). https://docs.stripe.com/webhooks