RFC 4231 test case (HMAC-SHA256)
what do ya want for nothing?
5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843
The official test vector from RFC 4231: key "Jefe".
Generate HMAC signatures with SHA-256, SHA-512, SHA-1, MD5 or SHA-3 from a message and a secret key, and verify webhook signatures by pasting the header value.
sha256= are removed automatically.what do ya want for nothing?
5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843
The official test vector from RFC 4231: key "Jefe".
what do ya want for nothing?
effcdf6ae5eb2fa2d27416d5f184df9c259a7c79
RFC 2202 test vector.
what do ya want for nothing?
✓ Valid signature
GitHub sends the HMAC in the X-Hub-Signature-256 header as sha256=<hex>.
HMAC (Hash-based Message Authentication Code) combines a hash function with a secret key to produce a signature that proves two things: the message has not been changed, and it was created by someone who knows the key. Anyone can calculate a plain SHA-256 of a message, but only the key holder can calculate its HMAC-SHA256. HMAC is defined in RFC 2104.
HMAC(K, m) = H( (K' ⊕ opad) ‖ H( (K' ⊕ ipad) ‖ m ) )The key is padded (or hashed first if it is longer than the block size), mixed with two constants (ipad = 0x36 bytes and opad = 0x5c bytes), and the message is hashed twice. This nested construction is why HMAC stays secure even with MD5 or SHA-1, whose collision weaknesses do not break HMAC in practice.
With SHA-256, SHA-1 and MD5, hash(key + message) is vulnerable to a length-extension attack: from a valid signature, an attacker can compute a valid signature for the message with extra data appended, without knowing the key. HMAC's double hashing prevents this. Always use HMAC, never a home-made key-plus-message hash.
| Service | Header | Algorithm |
|---|---|---|
| GitHub webhooks | X-Hub-Signature-256: sha256=… | HMAC-SHA256, hex |
| Stripe webhooks | Stripe-Signature: t=…,v1=… | HMAC-SHA256 of timestamp.body |
| Shopify webhooks | X-Shopify-Hmac-Sha256 | HMAC-SHA256, Base64 |
| Slack requests | X-Slack-Signature: v0=… | HMAC-SHA256 of v0:timestamp:body |
| JWT (HS256) | Third part of the token | HMAC-SHA256, Base64URL |
| AWS Signature Version 4 | Authorization | Chained HMAC-SHA256 |
Some providers sign more than the body (Stripe and Slack add a timestamp). Build the exact string they document before calculating the HMAC.
hash_equals, crypto.timingSafeEqual, hmac.compare_digest), never with ==.import { createHmac, timingSafeEqual } from 'node:crypto'; function verify(rawBody, header, secret) { const expected = 'sha256=' + createHmac('sha256', secret).update(rawBody).digest('hex'); const a = Buffer.from(expected); const b = Buffer.from(header); return a.length === b.length && timingSafeEqual(a, b);}$expected = 'sha256=' . hash_hmac('sha256', $request->getContent(), $secret); if (! hash_equals($expected, $request->header('X-Hub-Signature-256', ''))) { abort(403);}import hmac, hashlib expected = 'sha256=' + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()ok = hmac.compare_digest(expected, header)My webhook signature never matches
You are probably hashing a parsed body. Use the raw bytes exactly as received (in Laravel $request->getContent(), in Express express.raw()), and check the secret has no extra spaces or newline.
The signature is Base64 but I get hex
Shopify and some others send Base64. Choose Base64 under Format, or just paste the value into Verify: both forms are checked.
My provider gave me the key as hex or Base64
Set the key format to Hex or Base64. Using the hex string as text gives a completely different HMAC.
Stripe or Slack signatures do not match
They sign a combination such as timestamp.body (Stripe) or v0:timestamp:body (Slack), not the body alone. Build that exact string as the message.
Anyone can calculate a hash. An HMAC also needs a secret key, so it proves the message came from someone who knows the key and was not changed.
HMAC with SHA-1 is still considered secure in practice, and HMAC-MD5 has no practical break, but new systems should use HMAC-SHA256 or stronger.
No. The message stays readable; HMAC only adds a signature that proves integrity and authenticity.
No. The HMAC is calculated in your browser, and nothing you type leaves the page.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.