Skip to tool

HMAC Generator

Generate an HMAC authentication code for text or a file using a hexadecimal secret key.

Runs in your browser — your input is processed on this device and never uploaded.

Input

Pasted text up to 100 MiB, read as UTF-8, or files up to 2 GiB each.

Result

Results appear here.

About this tool

On this page

What is an HMAC?

An HMAC is a message authentication code: a tag computed from your data and a secret key, which shows the message came from a key holder and has not changed. Anyone can hash data. Only a holder of the key can produce a valid HMAC over it.

HMAC generator options

Secret key (hex)
Required. Hexadecimal bytes of the shared secret.
Message
Typed text or a file. Text can be up to 100 MiB, read as UTF-8, and a file up to 2 GiB.
Hash algorithm
SHA-256 (the default), SHA-384, SHA-512, SHA3-256 or SHA3-512. SHA-256 is the usual pick for interoperability.
Output
The tag in hexadecimal, plus the algorithm used.

Why not hash the key and message together

The obvious construction is broken. Hashing a secret followed by a message and publishing the result lets an attacker append data and compute a valid tag for the longer message without ever knowing the key, using the length-extension property of SHA-256 and SHA-512.

HMAC nests two hash operations with the key mixed in differently each time. That closes the hole for any underlying hash, which is why the standard construction is worth using rather than inventing your own.

HMAC alternatives

HMAC Verifier is the other half of this pair, for checking a tag rather than producing one.

If you need confidentiality as well as authenticity, an HMAC alone is the wrong shape. An AEAD such as AES-GCM or ChaCha20-Poly1305 does both in one operation and is harder to combine incorrectly. If you need to prove authorship to someone who does not share your key, no MAC can do that, because verification requires the same secret.

Things to know about HMAC

Verification needs the key, the message and the algorithm to match exactly. Changing any of the three produces a completely different tag, and a mismatch tells you nothing about which one was wrong.

Warning

Keep the key secret. An HMAC authenticates data without concealing it, so the message travels in the clear and anyone can read it. What they cannot do is alter it undetected.

Browse

Find similar tools by category or tag.