HMAC Generator

Compute an HMAC with Web Crypto, and compare it with an expected MAC when you paste one.

Use this tool

Result

The result appears in this panel after you run the tool.

About this tool

Web Crypto computes the HMAC for the algorithm you chose. If you paste an expected MAC, the page compares the two values without stopping at the first different character.

A missing or wrong key produces a different MAC. The page does not send either value out.

How to use it

  1. Paste the text and the key.
  2. Choose the hash. The compare field is optional.
  3. Compute the HMAC. A pasted MAC is compared on this page.

Limitations

A keyed MAC, compared in one pass

Web Crypto HMAC over UTF-8

The key and the message are both UTF-8. The key bytes are imported under Web Crypto’s raw format for HMAC, using SHA-256, SHA-384, or SHA-512, then applied to the message bytes. The panel prints the algorithm and the lowercase hex MAC. SHA-1 and MD5 are not on this menu. An empty key is not rejected by the form: it still derives a MAC, and that MAC will not match one produced with a real key. There is no separate salt and no iteration count. If you needed a slow password hash, this is the wrong construction.

A MAC is not encryption. The message stays in the box in the clear. The MAC lets someone who shares the key check that the message was not altered and that the key was the one you both used. Someone without the key should not be able to forge a new MAC. Someone with the message and no key learns nothing new about a hidden payload, because the payload was never hidden. It is also not a bare hash. The same message under two keys yields two MACs. The same message with no key at all, on the hash page, is a third value.

The optional expected value

If the expected field is empty, the page stops after printing the MAC. If you paste a value, the page compares it with a loop that does not return on the first differing byte: both strings are encoded as UTF-8, the lengths are folded into the difference, and each index is XORed through the longer length. The verdict is either that the MAC matches or that it does not. The comparison is of the hex text you see, not of raw MAC bytes re-decoded from hex, so a change in case or a stray space fails the check. A match means the hex strings are equal. It does not fetch a key from a server, and it does not validate a JWT. The JWT decoder never checks a signature. This page checks only the hex you pasted against the hex it just computed.

What to avoid

Refuse the MAC when someone asks for a password hash. There is no work factor. Do not treat a matching compare as a login system. The key lives in the form for this calculation. Do not publish the key beside the MAC and then call the message authenticated. Anyone who has both can forge. For an unkeyed fingerprint of a file, use the file checksum. For an unkeyed fingerprint of a paste, use the hash page, and keep MD5 and SHA-1 on the legacy side of that menu.

Privacy

Your input is processed in your browser and is not uploaded to UtilChain. File names, text, and results are not sent to analytics.