PBKDF2 Hash Generator
Turn a password and salt into a PBKDF2 derived key with the hash function, iteration count and key length you choose. Results appear as hex and Base64 together with ready-to-use encoded strings, the first steps of the calculation and matching Python and Node.js code. The key is computed by your browser's Web Crypto API and never leaves the page.
Last updated:
Calculation steps
Encoded hash strings
Code to reproduce this key
How to use the PBKDF2 Hash Generator
- Enter the password as plain text (encoded as UTF-8) or switch to Hex for raw bytes.
- Set the salt: keep the random 16-byte salt, press New random salt, or type your own as text, hex or Base64.
- Choose the hash, iterations and key length, or pick a preset such as OWASP SHA-256 (600,000 iterations) or Wi-Fi WPA2 (SHA-1, 4,096 iterations, 32 bytes).
- Press Generate key (it also updates as you type) and copy the hex, Base64 or encoded string you need.
- To check a stored value, paste it into Expected key: the tool tells you whether it matches.
- Open the steps and code panels to see how the key was built and to reproduce it in Python or Node.js.
How PBKDF2 works
PBKDF2 is specified in RFC 8018 (PKCS #5 v2.1). It takes a password P, a salt S, an iteration count c and a desired key length dkLen, and uses HMAC with a hash function as its pseudorandom function (PRF). With hLen = the hash output size:
- Split the output into blocks: l = ⌈dkLen ÷ hLen⌉. A 32-byte key with HMAC-SHA256 needs one block; a 64-byte key with HMAC-SHA256 needs two.
- First round of each block: U1 = HMAC(P, S ‖ INT(i)), where INT(i) is the block number i as a 4-byte big-endian integer (00000001 for the first block).
- Iterate: Uj = HMAC(P, Uj−1) for j = 2 … c.
- Fold: Ti = U1 ⊕ U2 ⊕ … ⊕ Uc (bitwise XOR of every round).
- Output: DK = T1 ‖ T2 ‖ … ‖ Tl, cut to the first dkLen bytes.
The total cost is c × l HMAC calls (each HMAC is two hash compressions or more). Because the password is the HMAC key in every round, an attacker who wants to test one guess must repeat all c rounds too. The salt makes every user's work unique, so one precomputed table cannot cover many accounts.
Recommended settings
| Hash (PRF) | Output size (hLen) | OWASP iterations (2023) | Natural key length |
|---|---|---|---|
| HMAC-SHA1 | 20 bytes (160 bits) | 1,300,000 | 20 bytes |
| HMAC-SHA256 | 32 bytes (256 bits) | 600,000 | 32 bytes |
| HMAC-SHA512 | 64 bytes (512 bits) | 210,000 | 64 bytes |
Figures are from the OWASP Password Storage Cheat Sheet as revised in 2023 and are meant to be raised as hardware gets faster. NIST SP 800-132 (2010) sets 1,000 iterations as the floor and asks for a random salt of at least 128 bits. Keep the key length at or below the hash output size when you store password hashes; for encryption keys, derive exactly what the cipher needs (32 bytes for AES-256).
Test vectors to check an implementation
| Source | Inputs | Derived key (hex) |
|---|---|---|
| RFC 6070 | HMAC-SHA1, P = “password”, S = “salt”, c = 1, dkLen = 20 | 0c60c80f961f0e71f3a9b524af6012062fe037a6 |
| RFC 6070 | HMAC-SHA1, P = “password”, S = “salt”, c = 4096, dkLen = 20 | 4b007901b765489abead49d926f721d065a429c1 |
| Common SHA-256 vector | HMAC-SHA256, P = “password”, S = “salt”, c = 1, dkLen = 32 | 120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b |
| Common SHA-256 vector | HMAC-SHA256, P = “password”, S = “salt”, c = 4096, dkLen = 32 | c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a |
| IEEE 802.11i (WPA2) | HMAC-SHA1, passphrase “password”, SSID “IEEE”, c = 4096, dkLen = 32 | f42c6fc52df0ebef9ebb4b90b38a5f902e83fe1b135a70e23aed762e9710a12e |
If your code disagrees with these values, the usual culprits are: the salt typed as text when the system expects hex bytes (or the reverse), a trailing newline in the password, a different text encoding than UTF-8, or comparing a hex string with a Base64 one.
Where PBKDF2 is used
- Password storage: Django's default hasher (pbkdf2_sha256), Werkzeug/Flask, passlib, and many FIPS-validated systems.
- Wi-Fi: WPA2-Personal turns your passphrase into the 256-bit pre-shared key with PBKDF2-HMAC-SHA1, 4,096 iterations and the network name as the salt.
- Encrypted files and vaults: password-protected archives, disk encryption and password managers derive their encryption key from the master password with PBKDF2 or a newer function.
- Browsers: the Web Crypto API exposes PBKDF2 natively, which is what this page uses.
For brand-new password storage without compliance constraints, a memory-hard function such as Argon2id or bcrypt resists GPU cracking better than PBKDF2 at the same time cost.
Frequently asked questions
What is PBKDF2?
PBKDF2 (Password-Based Key Derivation Function 2) is defined in PKCS #5, now RFC 8018. It turns a password and a salt into a key of any length by running a pseudorandom function, normally HMAC with SHA-1, SHA-256 or SHA-512, thousands of times. The repetition makes each password guess slow for an attacker.
How is a PBKDF2 key calculated?
The output is split into blocks the size of the hash. For block i, U1 = HMAC(P, S ‖ INT(i)), where INT(i) is i as a 4-byte big-endian number, then U2 = HMAC(P, U1) and so on up to Uc. The block is T_i = U1 ⊕ U2 ⊕ … ⊕ Uc. The blocks are concatenated and cut to the requested key length.
How many iterations should I use?
OWASP's Password Storage Cheat Sheet (2023) recommends 600,000 iterations for PBKDF2-HMAC-SHA256, 210,000 for PBKDF2-HMAC-SHA512 and 1,300,000 for PBKDF2-HMAC-SHA1. NIST SP 800-132 sets 1,000 as an absolute minimum. Choose the highest count your server can afford, and raise it over time.
How long should the salt be?
NIST SP 800-132 asks for a salt of at least 128 bits (16 bytes) from a secure random generator, unique for each password. The salt is not secret: it is stored next to the hash so the same key can be derived again at login.
Why should the key length not exceed the hash output size for passwords?
If you ask for more bytes than the hash produces (for example 64 bytes from SHA-256), PBKDF2 runs the whole iteration loop again for each extra block, but an attacker only needs the first block to test a guess. Your server does double the work for no extra security. Use SHA-512 if you need 64 bytes.
Is PBKDF2 still secure compared with bcrypt or Argon2?
PBKDF2 is still approved by NIST and required for FIPS-140 compliance, but it needs very little memory, so GPUs and custom hardware can test guesses in parallel cheaply. For new password storage OWASP prefers Argon2id, then scrypt or bcrypt; use PBKDF2 with a high iteration count where compliance or compatibility demands it.
Is my password sent to a server?
No. The key is derived with crypto.subtle.deriveBits in your own browser. The password, salt and result are not uploaded, logged or saved.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.