Toolvito

Works on this device

HMAC & Password Hash Calculator

Make an HMAC of a message with a secret key, or check one you received. Hash a password with PBKDF2 or scrypt, make a random salt, or match an older system that stores plain or NT hashes. The key and the password boxes are masked, and nothing is sent or saved.

HMAC or password hash

An HMAC is a hash made with a secret key. Only someone with the key can make the same HMAC, so it shows that a message was not changed.

The exact text or data the HMAC is for: spaces and line breaks count. For a webhook, paste the raw body as it was sent.

It is masked, is not sent or saved, and the result never shows it.

Many services give the key as text; some give it in hexadecimal or Base64. Choose the form your service uses.

More options

A text box holds each line break as one LF byte. Choose CR LF if the message was sent with Windows line breaks.

The key and the password are worked out in this browser. They are not sent or saved.

The result will show here

Type the values, or choose Try an example.

How to use the HMAC and password hash calculator

  1. Choose what to do: make an HMAC, check an HMAC, hash a password with PBKDF2 or scrypt, make a random salt, or make a plain or NT hash for an older system.
  2. Type the message, then the secret key or the password. The boxes are masked: choose Show to check what you typed, and it is masked again.
  3. Choose how the key, the message or the salt is written: plain text, hexadecimal or Base64. The same characters in another form are other bytes, so this choice must match your system.
  4. Choose Calculate or Check. Copy the result, or download it as a CSV file. The key and the password are never part of the result or the file.

What an HMAC is

An HMAC is a hash of a message made with a secret key (RFC 2104). Only someone who has the key can make the same HMAC, so a correct HMAC shows that the message was not changed and came from someone with the key. It is not encryption: the message itself is not hidden.

Many services sign webhooks and API requests this way. They send the HMAC in a header, often in hexadecimal and sometimes with a name in front, such as sha256=. To check one, choose Check an HMAC, paste the raw message exactly as it was sent, type the shared key and paste the HMAC. The algorithm is found from the length of the HMAC or from the name in front.

The key should be random and at least as long as the hash: 32 bytes for HMAC-SHA-256. RFC 2104 advises against shorter keys, and the result says when a key is shorter. To make a random key, use the Password Generator (Random key).

Hashing passwords

A stored password should be hashed with a slow function and a salt, so that a stolen list of hashes is slow to guess. A salt is random bytes, new for each password, stored beside the hash. It is not secret.

  • PBKDF2 (RFC 8018) runs HMAC many times. You choose the hash, the iteration count and the length. It is done by the Web Crypto of your browser.
  • scrypt (RFC 7914) needs much memory as well as time for each guess. You choose N (a power of 2), r and p; the memory is 128 × r × N bytes. Here it runs in a separate part of the page, so you can stop it.
  • Settings are yours to check. Advice on iteration counts and scrypt settings changes as computers get faster. Read current guidance, such as the OWASP Password Storage Cheat Sheet and NIST SP 800-63B and SP 800-132, or use the settings of the system you match. The example values of this page only let you try it; they are not advice.
  • To check a password against a stored PBKDF2 or scrypt hash, type the same salt, settings and length, and paste the stored hash under More options.

Why bcrypt and Argon2 are not offered

Web Crypto, the part of the browser that this page uses for HMAC and PBKDF2, does not offer bcrypt, scrypt or Argon2. This page offers an algorithm that it writes itself only when its tests can check it against the published test vectors of its specification. scrypt passes that check. bcrypt is described in a 1999 paper that gives no test vectors, and Argon2 (RFC 9106) has not been written and tested here yet. For bcrypt and Argon2, use the password library of your programming language or framework.

Plain hashes and the NT hash

  • Plain hash of a password: one MD5, SHA-1, SHA-2 or SHA-3 hash, with an optional salt before or after the password. Some older systems store passwords this way. It is not safe: a graphics card can try billions of such hashes a second.
  • NT hash (NTLM): the hash Windows stores for a password. It is MD4 (RFC 1320) of the password written in UTF-16LE, with no salt. It is used in some older network setups and test labs. MD4 is broken, and the same password gives the same NT hash everywhere.
  • Use these only to match a system that already uses them, and plan to move it to PBKDF2, scrypt, bcrypt or Argon2.

Your key and your password stay private

  • The secret key and the password are typed into masked boxes. They are worked out in this page and are not sent anywhere.
  • They are never saved on this device, never written into the CSV file, a copy or a printed page, and never put into the address of the page. Reset and leaving the page mask them again.
  • Results say only how long a key or a password is, never what it is.
  • It is still safer not to type a live production key or a password you use. A program on your computer or a browser add-on could see what you type. Test with a key or a password made the same way.

Worked example

With the key "key" written as plain text, the HMAC-SHA-256 of "The quick brown fox jumps over the lazy dog" is f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8. The key has only 3 bytes, so the result warns that it is shorter than the 32 bytes of SHA-256.

RFC 6070 gives a test of PBKDF2 with HMAC-SHA-1: the password "password", the salt "salt" written as plain text, 4,096 iterations and 20 bytes give 4b007901b765489abead49d926f721d065a429c1.

RFC 7914 gives a test of scrypt: "pleaseletmein" with the salt "SodiumChloride", N = 16,384, r = 8, p = 1 and 64 bytes. It needs 128 × 8 × 16,384 = 16,777,216 bytes (16 MiB) of memory, and the result starts with 7023bdcb3afd7348.

Limits you should know

  • HMAC with SHA-1, SHA-256, SHA-384 and SHA-512 only. HMAC-MD5 and HMAC with SHA-3 are not offered.
  • scrypt is limited to 256 MiB of memory (128 × r × N) and to N × r × p of at most 8,388,608, so that it ends in seconds, not minutes.
  • The page does not write the stored forms of particular systems, such as the SCRAM-SHA-256 lines of PostgreSQL, Unix crypt lines ($1$, $5$, $6$) or the hash strings of web frameworks. It gives the raw hash in hexadecimal or Base64.
  • A webhook that signs a string built from several parts (such as a time and the body) needs that exact string as the message.
  • This page cannot tell how fast your server will hash, and does not measure it.

Related tools