Skip to content
codinganthem
All tools/Security/HMAC Generator

HMAC Generator

Create HMAC-SHA256 and HMAC-SHA512 signatures online in hex or Base64. Free webhook signature generator for checking Stripe and GitHub; runs in your browser.

10 chars
More
Buy me a coffee

How to generate an HMAC SHA256 signature

Enter the message, such as a webhook's request body, and the secret key. Choose SHA-256 or SHA-512 and hex or Base64 output, and the signature appears to copy. The message and secret are encoded as UTF-8 and signed with the browser's Web Crypto API, so neither leaves your device.

HMAC-SHA256(message "hello", secret "secret")
hex     88aab3ede8d3adf94d26ab90d3bafd4a2083070c3bcce9c014ee04a443847c0b
Base64  iKqz7ejTrflNJquQ07r9SiCDBww7zOnAFO4EpEOEfAs=

Use this pair to check that your own code produces the same result.

What HMAC is

  • HMAC combines a secret key with a hash function to sign a message. Anyone with the same key can recompute the signature and confirm the message wasn't changed and came from someone who knows the key.
  • It isn't encryption: the message stays readable. It proves integrity and authenticity.
  • SHA-256 gives a 64-character hex signature and is what most webhooks use. SHA-512 gives 128 hex characters.
  • Hex and Base64 are two ways of writing the same bytes. Use whichever the service you're checking uses.

Verifying a webhook signature

  • Take the raw request body exactly as received. Parsing the JSON and serialising it again changes spaces or key order, and the signature no longer matches.
  • Some providers sign more than the body. Stripe, for example, signs a timestamp and the body together, so build the same signed string their documentation describes.
  • Compute the HMAC with your signing secret and compare it with the header the provider sends. GitHub, for example, sends X-Hub-Signature-256: sha256= followed by the hex signature.
  • In production code, compare signatures with a constant-time function, such as crypto.timingSafeEqual in Node.js, not ==.

For a plain hash with no key, use the Hash Generator.

Frequently asked questions

How do I generate an HMAC SHA256 online?+

Enter the message and the secret, keep SHA-256 selected, and copy the signature in hex or Base64. It's computed in your browser.

Why doesn't my webhook signature match?+

Usually the body was changed before signing, for example parsed and re-serialised as JSON, or the provider signs a timestamp with the body. Sign the raw body exactly as received, in the format the provider documents.

Should I use hex or Base64?+

Whichever the service uses: they're the same bytes written differently. GitHub uses hex; some other providers use Base64.

Is my secret sent to a server?+

No. Signing uses the Web Crypto API in your browser. Still, don't leave a production secret in a browser on a shared computer.