An API guide tells you to send an HMAC signature, and the tool in front of you offers three hashes: SHA-256, SHA-384 and SHA-512. The instinct is to assume one of them must be the weak one, and that picking wrong is a security mistake waiting to happen. So you stall on a dropdown that was never the risky part.

This guide settles the question with the free HMAC Generator on Ovatly, which signs a message with a shared secret key via Web Crypto and shows the signature in hex and Base64. The short version: both choices are sound, the deciding factors are practical, and the key deserves far more attention than the hash.

Contents

  • Quick answer
  • What the hash choice actually changes
  • Factor one: what the other system expects
  • Factor two: signature length
  • Factor three: platform speed
  • Where SHA-384 fits
  • How to compare the options, step by step
  • Worked example: the fox test value under SHA-256
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Use the hash the receiving system expects. If you are free to choose, HMAC-SHA-256 with a random key of 32 bytes or more is a sound default, and HMAC-SHA-512 is equally sound when you want the longer signature or your platform favours it. Open the HMAC Generator, paste the exact message, enter the secret key, pick the named hash, compute, and copy the signature in the format that system expects, hex or Base64.

What the hash choice actually changes

An HMAC signs a message with a shared secret key. The hash you pick decides the size of the signature, and it changes the resulting value completely: the same message and key produce one signature under SHA-256 and a different, longer one under SHA-512.

What the choice does not change is the nature of the result. Either way you get an authentication signature, not encryption: an HMAC proves a message came from someone holding the key and was not altered, and the message itself stays readable. Verification is unchanged too: sign again with the same key and hash, then compare. The generator offers SHA-256, SHA-384 and SHA-512 only; HMAC-SHA-1 and MD5 are deliberately omitted, so the menu itself removes the options that would need a warning.

Factor one: what the other system expects

Interoperability decides first, and it is not close. A signature only works if the receiver can reproduce it, and the receiver reproduces it with the hash its documentation names. Sign with SHA-512 when the receiver expects SHA-256 and verification fails, not because either hash failed, but because the two sides never agreed. So the first step is reading, not choosing: the documentation usually names the algorithm next to the signature header it expects, and that name is your answer. When it offers a choice, or you control both ends, the other two factors decide it.

Factor two: signature length

The visible difference is size. An HMAC-SHA-256 signature is 64 hex characters. SHA-384 produces 96. SHA-512 produces 128, twice as many as SHA-256. In Base64 the same bytes encode more compactly, but the ordering is unchanged: SHA-512 longest, SHA-256 shortest.

Length matters where signatures are stored, logged or sent in headers alongside every request. A longer signature is a real, countable cost, and it buys its length in output size rather than in a fix for any defect in the shorter one. If nothing else decides the question, the shorter signature the other system accepts is the tidy choice.

Factor three: platform speed

The third factor is how each hash runs on the machine doing the signing. SHA-512 works in larger blocks and is comfortable on 64-bit systems, which covers most modern servers and computers, so on that hardware it can be an efficient choice at large volumes. SHA-256 is the lighter, more universal option and runs well everywhere. For the volumes most integrations handle, signing speed rarely becomes the bottleneck, so treat this as a tiebreaker rather than the main event: it never turns a sound hash into an unsound one.

Where SHA-384 fits

SHA-384 sits between the two: a 96 hex character signature, longer than SHA-256 and shorter than SHA-512. It exists on the menu for the same interoperability reason as the others: some systems name SHA-384 specifically, and when one does, it is the correct choice for that system. Its middle position does not make it a compromise to default to; it is simply the third offered option.

How to compare the options, step by step

  1. Open the HMAC Generator and paste a test message exactly, byte for byte. Whitespace and line endings are part of the message, so a trailing newline changes the signature completely.
  2. Enter a test key. For a real integration, use a random key of 32 bytes or more.
  3. Pick SHA-256 and compute the HMAC. Note the signature and its length in hex.
  4. Switch to SHA-512 and compute again with the same message and key. Compare the length and confirm the value is entirely different.
  5. Copy the signature in the format the receiver expects, hex or Base64: the same bytes in two encodings, so use the one it specifies.

Worked example: the fox test value under SHA-256

The published test value for this tool uses the key key and the message The quick brown fox jumps over the lazy dog. Under SHA-256 it gives:

f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8

Count it: 64 hex characters. Run the same message and key under SHA-512 and the signature stretches to 128 hex characters, exactly twice as many, with no visible resemblance to the SHA-256 value. That pair of runs is the comparison in miniature: same message, same key, same tool, two sound signatures differing in length and nothing you need to worry about. It also gives you a known-answer check: if your own setup reproduces the fox value under SHA-256, your signing path is wired correctly before you trust it with a real payload.

Limitations and honest tradeoffs

This tool signs on your device only, but never sign production secrets on an untrusted machine. The generator also cannot make a decision the documentation has already made: when a receiver names its hash, this comparison is moot.

An HMAC authenticates; it does not encrypt, and anyone with the key can sign as well as verify, so HMAC suits shared-secret setups rather than public-key signatures. You cannot decrypt an HMAC or work backwards from a signature to the key or message. Verification is always the forward operation repeated: sign again, compare.

Common mistakes

  • Choosing the hash by gut feeling about strength. The offered hashes are all sound. Receiver expectation, signature length and platform are the real factors.
  • Signing with one hash and verifying with another. The comparison can never match. Both sides must use the same hash, key and bytes.
  • Treating a mismatch as a hash problem. A mismatch is almost always byte-level: a trailing newline, an encoding difference, a hex key treated as text or the reverse, or a re-serialised payload.
  • Inventing a memorable key. The key is the security. A random key of 32 bytes or more does the work; a memorable phrase does not.
  • Sending the signature in the wrong encoding. Hex and Base64 are the same bytes written two ways, but the receiver expects one specific form. Send that one.

FAQs

Is SHA-512 stronger than SHA-256 for an HMAC? Both are offered because both are sound. The practical differences are the longer SHA-512 signature and how each performs on your platform, not a weakness in SHA-256. Pick the one the other system expects, and spend your effort on a proper random key instead.

Why does the generator not offer HMAC-SHA-1 or HMAC-MD5? Only SHA-256 and stronger are offered, and HMAC-SHA-1 and MD5 are deliberately omitted. If a system asks you for one of those, that is a limitation of that system, not a setting you are missing here.

How long is an HMAC-SHA-512 signature compared with SHA-256? Twice as many hex characters. An HMAC-SHA-256 signature is 64 hex characters, an HMAC-SHA-384 signature is 96, and an HMAC-SHA-512 signature is 128. In Base64 the same ordering holds: the SHA-512 value is the longest of the three.

What key should I use for HMAC-SHA-256? A random key of 32 bytes or more is a sound default for HMAC-SHA-256. Generate it randomly rather than inventing a memorable phrase, keep it secret, and remember that anyone holding the key can both sign and verify.

Does the choice of hash change how verification works? No. Verification means signing the same message again with the same key and the same hash, then comparing the two signatures. If the hash differs between signing and verifying, the comparison fails even when the message and key are identical.

Conclusion

Between SHA-256 and SHA-512 there is no wrong answer, only a fitting one: match the hash the other system expects, let signature length and platform comfort break any tie, and put your real care into a random key of 32 bytes or more. The HMAC Generator offers exactly the sound options, SHA-256, SHA-384 and SHA-512, and nothing weaker. For the signing workflow itself, see how to sign a test webhook payload with HMAC, and for more guides in this series, see our Security and Privacy guides.

References