Back to guides

HMAC Generator|Sign and verify webhook payloads with SHA-256

Compute HMAC-SHA256 (or SHA-1/384/512) over the raw message with your shared secret—hex output for Stripe-style webhooks, all in the browser.

By WGinit · November 26, 2026 · 6 min read · 11 views

What HMAC solves here

Payment, shipping, and SCM webhooks sign the raw HTTP body with a shared secret and ship a hex digest in headers like X-Signature or Stripe-Signature. During integration you recompute locally to learn whether concatenation order, secret env, or algorithm choice is wrong.

Versus Hash Generator: plain hashes lack a key; HMAC mixes the secret so tampered bodies cannot be re-hashed without knowing it. JWT HS256 is HMAC-shaped but structured; this tool is the free-form message + secret + algorithm case.

HMAC Generator calls Web Crypto subtle.sign, algorithms SHA-1 / SHA-256 / SHA-384 / SHA-512, output lowercase hex. Message and key pass through UTF-8 TextEncoder, matching many Node createHmac('sha256', secret).update(msg).digest('hex') recipes—still read vendor docs for Base64 MAC or sha256= prefixes.

Document which environment (test vs live) supplied the secret in your ticket so the next engineer does not chase ghosts.

Partner sandboxes often rate-limit webhook retries; a single MAC mismatch can queue dozens of failing events. Fixing the signing string once stops the noise faster than silencing alerts.

Fill the form like the vendor doc

Message: the exact signing string—usually raw body bytes as text, including newline choices. Secret: signing key; Stripe-style values often start whsec_.

Pick the algorithm: default SHA-256 for new hooks; legacy Git hooks may insist on SHA-1. Changing the dropdown changes every nibble—do not confuse this with JWT alg.

Generated hex compares to header material case-insensitively; some platforms embed it inside t=...,v1=... strings—extract the v1 segment.

WoDeTool does not store message or secret server-side. Close the tab after staging tests; never paste live whsec into public screenshots.

If the platform documents constant-time comparison, implement that in your server after you trust the hex output here—browsers are for human verification, not timing-safe production compares.

Some platforms base64-wrap the secret before HMAC; WoDeTool expects the signing key as you would type it into a Node one-liner. Decode or prefix-strip per doc before paste.

Wire into your debug chain

Replay with HTTP Request, copy raw response/body into message—pretty JSON from a tree view often breaks MAC match.

Use JSON Formatter to read structure only; signing input must mirror capture tools' raw view.

When docs demand Base64-decoded key material, this page treats the secret as text—decode in Base64 first if your runbook says so, or use a script.

JWT HS256 verification is out of scope; claims live in the JWT expiry guide.

Keep a single canonical sample body in the repo README for partners; rotate it when the schema changes.

Verification flow (diagram)

Order: capture raw → MAC here → compare header → only then change application code.

Failure triage (diagram)

HMAC does not stop replay: captured valid bodies can be resent inside tolerance windows—pair with timestamp headers per vendor spec.

FAQ

QWhy hex not Base64?

AThis page emits hex; convert externally if the doc demands Base64.

QEmpty message?

ABoth fields are required or the UI errors; empty string only if your spec truly allows it.

QSame as file SHA-256?

ANo—file hashes lack a keyed MAC step.

QSecret logging?

ANot uploaded; computed in browser memory only.

Worked example (step by step)

1. Body {"orderId":"ORD-9","amount":1200} without trailing spaces.

2. Paste staging whsec_test_... into secret.

3. SHA-256 → hex local_mac.

4. Compare X-Hub-Signature-256: sha256=... hex portion.

5. On mismatch, HTTP Request replay and diff strings character-wise.

6. If doc requires timestamp + '.' + body, build that string before signing.

7. Rotate secrets per runbook; never commit whsec to git.

8. Note algorithm and secret env in the PR for the next on-call.

Vendor pattern notes

Stripe-style signatures concatenate timestamp and body with a dot; Twilio and older gateways sometimes HMAC only the raw POST bytes. Read the paragraph that names the exact byte sequence before you paste into the message box—adding a UTF-8 BOM or trailing newline is enough to fail an otherwise correct secret.

GitHub webhooks historically shipped X-Hub-Signature with sha1= prefixes while newer repos document sha256=; the dropdown on WoDeTool must match the prefix your handler verifies, not whichever algorithm you prefer.

Shopify and similar platforms rotate shared secrets; keep a row in your runbook listing which secret belonged to which deploy window so you do not compare a live MAC against a stale whsec.

When the vendor offers both HMAC and asymmetric signatures, treat this page as the symmetric path only; do not paste private keys here.

Payment processors sometimes publish separate test vectors for refund webhooks; copy those bodies verbatim rather than hand-writing JSON, because field order may differ from create events even when the schema looks identical.

If your framework parses JSON before verification, pause: middleware may mutate whitespace; sign the bytes the gateway sent on the wire, captured in your proxy or integration test.

From browser MAC to production code

After you match headers in staging, port the recipe to your service using the same UTF-8 encoding assumption. Node, Go, and Java standard libraries all expose HMAC helpers; the browser output on WoDeTool is a reference vector, not a substitute for unit tests in CI.

Store expected MAC vectors in contract tests: body fixture, secret fixture, expected hex. When the platform changes newline handling, update the fixture before you chase ghosts in application logic.

If your load balancer injects chunked transfer decorations into logged bodies, sign the bytes your application reads, not the prettified log copy.

For replay debugging, the staging HTTP request guide keeps method, headers, and raw payload aligned—recompute MAC on the same string you actually sent.

Framework middleware order matters: if JSON parsers run before signature verification, you may verify a mutated object while the gateway signed raw bytes—align middleware with the vendor diagram, then use this page to validate your first successful vector.

Blue-green deploys that change secrets without dual-signing windows create confusing MAC failures; document which color still owns the old secret for at least one release.

Release checklist

Attach matched header hex, algorithm choice, and the first 80 characters of the raw body to the integration ticket so the next engineer does not re-litigate newline semantics.

When secrets rotate, re-run the browser MAC once per environment and archive the vector in your secret manager notes—not in git.

Copy-paste reference

In HMAC Generator, set algorithm SHA-256, message to the raw JSON body bytes (no extra spaces), secret to your webhook key — compare the hex output to your receiver.

POST /webhooks/pay HTTP/1.1
Content-Type: application/json
X-Signature-SHA256: <paste hex from HMAC tool>

{"orderId":"ORD-9","amount":19900}

Related tools

Related guides