JustGenerator
Hashing 100% Client-Side Privacy

HMAC-SHA256 & SHA-512 Generator

Generate and verify Hex or Base64 HMAC message authentication codes locally using the Web Crypto API for Stripe, GitHub, Shopify, and custom API webhooks.

0 bytes
0 bytes

Debugging webhook signatures without leaking secrets

Webhook signature mismatches are one of the most annoying integration bugs because the error is almost always a single invisible byte. When GitHub sends X-Hub-Signature-256, Shopify sends X-Shopify-Hmac-Sha256, or Stripe sends Stripe-Signature, your backend has to reproduce the exact HMAC digest from the shared secret and the unmodified HTTP body.

This page runs crypto.subtle.importKey("raw", ...) and crypto.subtle.sign("HMAC", ...) directly inside your browser tab. Your webhook signing secret and customer payload stay on your own machine. Paste the secret, drop in the raw payload, and check the live byte counters to confirm you are signing the exact string your server received.

Three provider quirks that break HMAC checks

If your server signature does not match what you compute here, check these three platform-specific details:

  • GitHub prepends sha256= to the lowercase hex digest in X-Hub-Signature-256. Our comparison input strips sha256=, sha512=, and v1= prefixes automatically when checking for a match.
  • Stripe does not sign the raw JSON body alone. It signs <timestamp>.<raw_body> using the t= value from the Stripe-Signature header separated by a literal period.
  • Shopify encodes its HMAC-SHA256 digest in standard Base64 rather than Hex. Switch the Output Encoding dropdown to Base64 when comparing against Shopify headers.

Why you should never roll your own hash(secret + message)

Concatenating a secret key and a message inside plain SHA-256 or SHA-512 is vulnerable to length-extension attacks on Merkle-Damgard hash functions. RFC 2104 HMAC hashes the key and message in two nested passes with inner and outer padding constants (0x36 and 0x5c), closing that attack vector cleanly.

Need a fresh 256-bit webhook signing secret before wiring up HMAC? Generate one with a whsec_ prefix in our Random Token Generator. If you are inspecting signed HS256 JSON Web Tokens, use our JWT Decoder & Inspector.

Common questions

How do I verify an HMAC-SHA256 webhook signature on my server?

Read the raw HTTP request body before JSON middleware parses it, compute HMAC-SHA256 using your shared webhook secret and those exact raw bytes, and compare the digest against the incoming header using a constant-time function such as crypto.timingSafeEqual in Node.js or hmac.compare_digest in Python.

Why does my HMAC webhook signature fail even when the secret is right?

The most frequent culprit is re-serializing parsed JSON instead of hashing the raw request bytes, which changes whitespace or key order. Other common causes are forgetting to strip prefixes like sha256= from GitHub headers, mixing up Hex and Base64 output formats, or omitting the timestamp prefix that Stripe prepends (timestamp + "." + rawBody).

What is the difference between Hex and Base64 HMAC output?

Both represent the exact same 32-byte (SHA-256) or 64-byte (SHA-512) MAC digest. Hex outputs 64 lowercase characters (used by GitHub, Stripe, and Slack), whereas Base64 outputs 44 characters ending with = (used by Shopify and Twilio webhooks).

How do I prevent webhook replay attacks with HMAC?

An HMAC proves that the payload was signed with your secret and was not modified in transit, but an attacker who captures a valid request could send it again later. Sign a Unix timestamp alongside the payload and reject any request whose timestamp is older than 5 minutes.

What is the difference between SHA-256 and HMAC-SHA256?

Plain SHA-256 takes only one input (the message), so anyone can recompute it. HMAC-SHA256 combines a shared secret key with the message using a two-pass inner/outer padding construction defined in RFC 2104, preventing length-extension attacks and proving authenticity.

How do I generate an HMAC-SHA256 signature in the terminal?

Run printf "your_payload" | openssl dgst -sha256 -hmac "your_secret" on macOS or Linux. Using printf instead of echo avoids appending a hidden trailing newline byte that would change the signature.