Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

HMAC Generator & Webhook Signature Verifier

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.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 BUTF-8
HMAC-SHA256

Runs in your browser. Your key never leaves this page. Tip: paste a webhook header to verify it

How to use the HMAC tool#

  1. Enter the Secret key. Choose Text, Hex or Base64 to match how your provider gives you the key.
  2. Paste the Message: for webhooks, the raw request body exactly as received.
  3. Pick the Algorithm (HMAC-SHA256 is the most common) and the output Format.
  4. To verify, paste the signature from the header into Verify a signature. Prefixes such as sha256= are removed automatically.

Examples#

RFC 4231 test case (HMAC-SHA256)

Input
what do ya want for nothing?
Output
5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843

The official test vector from RFC 4231: key "Jefe".

Same message with HMAC-SHA1

Input
what do ya want for nothing?
Output
effcdf6ae5eb2fa2d27416d5f184df9c259a7c79

RFC 2202 test vector.

Verify a GitHub-style webhook header

Input
what do ya want for nothing?
Output
✓ Valid signature

GitHub sends the HMAC in the X-Hub-Signature-256 header as sha256=<hex>.

What is HMAC?#

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.

How HMAC works#

plaintext
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.

Why not just hash(key + message)?#

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.

Where HMAC is used#

ServiceHeaderAlgorithm
GitHub webhooksX-Hub-Signature-256: sha256=…HMAC-SHA256, hex
Stripe webhooksStripe-Signature: t=…,v1=…HMAC-SHA256 of timestamp.body
Shopify webhooksX-Shopify-Hmac-Sha256HMAC-SHA256, Base64
Slack requestsX-Slack-Signature: v0=…HMAC-SHA256 of v0:timestamp:body
JWT (HS256)Third part of the tokenHMAC-SHA256, Base64URL
AWS Signature Version 4AuthorizationChained 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.

Verifying a webhook safely#

  • Hash the raw request body, not a parsed and re-encoded JSON object: whitespace and key order change the bytes.
  • Compare signatures with a constant-time function (hash_equals, crypto.timingSafeEqual, hmac.compare_digest), never with ==.
  • Reject old timestamps when the provider includes one, to stop replay attacks.

HMAC in code#

Node.js (verify a GitHub webhook)#

javascript
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);}

PHP / Laravel#

php
$expected = 'sha256=' . hash_hmac('sha256', $request->getContent(), $secret); if (! hash_equals($expected, $request->header('X-Hub-Signature-256', ''))) {    abort(403);}

Python#

python
import hmac, hashlib expected = 'sha256=' + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()ok = hmac.compare_digest(expected, header)

Common errors and fixes#

  • 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.

Frequently asked questions#

What is the difference between a hash and an HMAC?

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.

Is HMAC-SHA1 or HMAC-MD5 still safe?

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.

Is HMAC encryption?

No. The message stays readable; HMAC only adds a signature that proves integrity and authenticity.

Is my secret key sent anywhere?

No. The HMAC is calculated in your browser, and nothing you type leaves the page.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.