Upload a file
  1. base64hub
  2. Keys & hashes
  3. HMAC generator

HMAC Generator (Base64)

Enter the message and the secret key to get the HMAC signature in Base64, Base64URL and hex. Use it to debug webhook signatures and API request signing without sending the secret anywhere.

Free no sign-up, no limits Local nothing uploaded Key as text, hex or Base64 bytes Updated Oct 27, 2026

Processed in your browser. This page cannot send your data anywhere – how we know

How to compute an HMAC in Base64

  1. HMAC mode and SHA-256 are selected. Pick another algorithm under Algorithm if your API uses SHA-1, SHA-384, SHA-512 or MD5.
  2. Enter the Secret key and set Key is: Text (UTF-8) for a normal secret string, Hex or Base64 if the key is given as encoded bytes.
  3. Type or paste the message into Text, or switch Input to File and drop the exact payload file.
  4. Copy the signature as Base64, Base64URL or hex. All algorithms shows the HMAC with every hash at once, which helps when the documentation is vague about which one is used.

An empty key is accepted and still gives a result, with a note that such an HMAC protects nothing.

Example values

With the key key and the message The quick brown fox jumps over the lazy dog:

AlgorithmHMAC in Base64
HMAC-MD5gAcHE0Y+d0m5DC3CSRHidQ==
HMAC-SHA13nybhbi3iqa8ino29wqQcBydtNk=
HMAC-SHA25697yD9DBThCSxMpjmqm+xQ+9NWaFJRhdZl0edvC0aPNg=
HMAC-SHA512tCrwkFe6weLUFwjkipAuCbX/fxKrQopP6GZTxz3SSPuC+UilSfe3kaW0GRXuTR7Dk1NX5OIxclDQNyr6Lr7rOg==

The HMAC-SHA256 value in hex is f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8, the familiar test vector from the Wikipedia article on HMAC. Key encoding changes the result: the text a2V5 used as a key gives 5O+7AtpguFrgIRw1qXGU+m0OaTs1oV1kwRQ/hI1WAUE=, while a2V5 read as Base64 is the bytes of key and gives 97yD9DBT… again.

Webhook signatures: Base64 or hex

Providers agree on HMAC but not on the output encoding or on what is signed. A few well-documented examples:

ProviderHeaderAlgorithmEncodingSigned content
ShopifyX-Shopify-Hmac-Sha256HMAC-SHA256Base64raw request body
Standard Webhooks (Svix)webhook-signature: v1,…HMAC-SHA256Base64id.timestamp.body, key from whsec_ Base64
TwilioX-Twilio-SignatureHMAC-SHA1Base64URL plus sorted POST parameters
GitHubX-Hub-Signature-256: sha256=…HMAC-SHA256hexraw request body
StripeStripe-Signature: t=…,v1=…HMAC-SHA256hextimestamp.body

When a value from this tool matches the hex but your code compares Base64, or the other way round, the computation is right and only the encoding differs. Check the provider’s documentation for what is signed; the timestamp prefixes exist to stop replays of old requests.

Verifying a signature in code

Compare raw bytes in constant time, and make sure you hash the body exactly as received:

const crypto = require("crypto");

function verifyWebhook(rawBody, secret, signatureHeader) {
  const expected = crypto.createHmac("sha256", secret).update(rawBody).digest();
  const given = Buffer.from(signatureHeader, "base64");
  return given.length === expected.length && crypto.timingSafeEqual(given, expected);
}

With rawBody as the Buffer of the fox sentence, secret key and the Base64 value from the table, it returns true. Feed it JSON.stringify(JSON.parse(body)) instead of the raw body and it returns false as soon as the provider’s JSON had a space your serializer drops. In Express, that means reading the body with express.raw() on the webhook route.

The Python equivalent uses hmac.new(key, body, hashlib.sha256).digest(), Base64-encodes it and checks with hmac.compare_digest. For the command line, openssl dgst -sha256 -hmac 'key' -binary | base64 gives the same Base64; use -mac HMAC -macopt hexkey:… when the key is hex. For a strong key, the HMAC secret preset of the Base64 key generator makes 32 random bytes. For signed tokens rather than signed requests, see the JWT encoder.

FAQ

Why does my webhook HMAC not match?

The signature covers the exact bytes of the request body. If your framework parsed the JSON and you hash a re-serialized copy, spacing or key order changes and the result differs. Hash the raw body, check whether the provider expects hex or Base64, and check whether the secret must be decoded first.

Is the HMAC secret text or Base64?

It depends on the provider. Most give you a string that is used as UTF-8 text. Some hand out a Base64-encoded key, sometimes after a prefix like whsec_, which must be decoded to bytes before use. Set Key is to match.

What is the difference between a hash and an HMAC?

Anyone can compute the SHA-256 of a message, so a hash only detects accidental changes. An HMAC mixes in a secret key, so only someone who holds the key can produce a valid value, which makes it a signature.

Can I use HMAC-MD5 or HMAC-SHA1?

Both are still in use by older APIs and remain much stronger than plain MD5 or SHA-1, because collisions do not translate into HMAC forgeries. For new designs choose HMAC-SHA256.