HMAC Generator – Generate HMAC SHA256 Online Free

Use the free HMAC Generator below: your data never leaves your browser — all work happens on your device, and nothing is uploaded to any server.

HMAC: the signature that proves a message is genuine

Imagine you run a shop and your payment provider sends you a message saying “order 42 was paid”. How do you know the message really came from the provider and not from someone pretending to be them? That is the problem HMAC solves. HMAC, short for Hash-based Message Authentication Code, mixes a secret key with a message and produces a short fingerprint. Only someone who knows the secret key can produce the right fingerprint for a given message. If the fingerprint matches, the message is genuine and unaltered. If it does not, something is wrong.

The key idea is the secret. A plain hash like SHA-256 of a message proves nothing about who wrote it, because anyone can compute the same hash. Adding a secret key changes that. The recipient, who also knows the key, recomputes the HMAC and compares. An attacker who does not know the key cannot forge a valid fingerprint for a fake message, even though the algorithm itself is public. This is the same principle behind signed webhooks from Stripe, GitHub and Slack: the provider signs each delivery with a shared secret, and your server verifies the signature before trusting the payload.

How HMAC works, in plain language

HMAC does not just stick the key in front of the message and hash the result. That naive approach has known weaknesses. Instead, it hashes the key together with the message twice, with two different padding constants, in a construction that cryptographers have studied for decades. The practical upshot is simple: HMAC-SHA256 takes any key and any message and produces a 256-bit output, shown here as 64 hex characters or in base64. The same key and message always give the same output. Change one character of the message, or one character of the key, and the output changes completely.

This tool computes HMAC with your browser’s built-in Web Crypto engine, the same cryptographic code your browser uses for secure websites. You can choose SHA-256, SHA-384 or SHA-512. SHA-256 is the standard choice and is what most APIs expect. SHA-512 gives a longer output and is used where a larger security margin is wanted. Your key and message never leave this page: the computation happens locally, and nothing is sent to any server, including ours.

Where HMAC is used in real systems

The most common use is API authentication. Instead of sending a password with every request, a client signs the request with its secret key and sends the signature alongside it. The server recomputes the signature and accepts the request only if it matches. This proves the client holds the key without ever sending the key itself. Amazon’s AWS signatures, many payment gateways and webhook systems all work this way.

HMAC is also the signature inside JWT tokens, the compact tokens used for web login sessions. A JWT signed with HS256 is exactly an HMAC-SHA256 over the token’s header and payload. If you use the JWT tool on this site, you are using HMAC under the hood. The same construction appears in TOTP two-factor codes, where HMAC over the current time produces the six-digit code on your phone.

Handling keys honestly

HMAC is only as safe as its key. A short, guessable key like “secret” can be brute-forced, because an attacker who knows the message can try candidate keys until the fingerprint matches. Use a long random key, at least 32 characters, generated by a proper random source. Never put a real production key into a website you do not trust, and never commit one to a public code repository. Keys that leak should be rotated immediately, because every message ever signed with them can then be forged.

Also remember what HMAC does not do. It proves authenticity and integrity, but it does not hide the message. Anyone can read the message itself; only the signature is secret-dependent. If the message must stay private, encrypt it as well. And HMAC alone does not prove freshness: an attacker could replay an old signed message. Real systems add timestamps or nonces to stop replays.

Common questions

Why does the same input always give the same output? HMAC is deterministic by design, so verification is just recomputation and comparison. Should the key be the same length as the hash output? Keys longer than the hash block size are hashed down first, so very long keys work but add no extra strength beyond the hash size. Is my key uploaded? No. Web Crypto runs locally in your browser, and this page sends nothing anywhere.

Related tools

1 thought on “HMAC Generator – Generate HMAC SHA256 Online Free”

  1. Pingback: Hash Type Identifier - Identify a Hash Algorithm Free Online

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top