Key Derivation Lab
Derive keys with PBKDF2, scrypt, Argon2id and HKDF; compare costs with OWASP advice.
How it works
Derives keys from a password and salt with PBKDF2 (SHA-1/256/512), scrypt, Argon2id and HKDF using the parameters you choose, and compares their memory and work settings with the OWASP Password Storage recommendations. With JavaScript on, the page shows real timings for PBKDF2, HKDF and scrypt.
- PBKDF2 (RFC 8018) repeats HMAC with the chosen hash; its cost is the iteration count and it needs almost no memory, so GPUs attack it efficiently.
- scrypt (RFC 7914) needs about 128 × N × r bytes of memory per derivation, which makes large-scale guessing expensive. Argon2id (RFC 9106, winner of the Password Hashing Competition) is configured by memory m, passes t and lanes p; OWASP recommends it first.
- HKDF (RFC 5869) extracts and expands keys from input that is already random (for example a Diffie–Hellman secret); it is fast and must not be used to hash passwords.
- "Meets OWASP" compares your parameters with the minimums of the OWASP Password Storage Cheat Sheet (Argon2id m/t combinations; scrypt N×r ≥ 2^17×8; PBKDF2 1,300,000 / 600,000 / 210,000 iterations for SHA-1 / SHA-256 / SHA-512).
- Server and API results contain no timings, so the same input always gives the same result. With JavaScript on, the page derives PBKDF2 and HKDF with WebCrypto and scrypt with a built-in JavaScript implementation and shows how long each took. Argon2 is not available in browsers, so it needs the server (you are asked first).
Never reuse the example salts. For real password storage use a maintained library that encodes parameters and salt (e.g. the PHC string format).
Sources
Use this tool in an app
These free programs for your browser have this tool built in, next to everything else the task needs.
-
Keysmith Crypto & secrets lab
Audit certificates, keys, TLS and passwords in one lab; server runs ask first.
Related tools
- Hash & HMAC Calculator – MD5, SHA-2, SHA-3, BLAKE2, CRC32 and HMAC of text or files, with checksum compare.
- Local File Encryption Studio – Encrypt and decrypt files with AES-256-GCM and a password.
- Password & Passphrase Generator – Strong random passwords and passphrases with exact entropy.
How to use the Key Derivation Lab
Derive keys with PBKDF2, scrypt, Argon2id and HKDF, reproduce RFC test vectors, and see whether your cost settings meet the OWASP minimums.
What it is for
If you store passwords or turn a passphrase into an encryption key, the function and its parameters matter more than almost anything else. PBKDF2 with 1,000 iterations falls quickly to a GPU, while Argon2id with sensible memory settings does not. This lab derives the same password with several functions side by side and checks each setting against the minimums in the OWASP Password Storage Cheat Sheet.
It supports PBKDF2 with SHA-1/256/512, scrypt (N, r, p), Argon2id (memory, passes, parallelism) and HKDF-SHA-256/512. You choose the salt, output length and encoding. It's also handy for checking your own implementation against known test vectors from RFC 7914 and others.
HKDF is included for comparison and for its real job: expanding key material that is already random, such as a Diffie–Hellman secret. It does no stretching and must never be used on passwords.
Worked example
With the defaults, password correct horse battery staple and the 16-byte salt c2FsdHNhbHRzYWx0c2FsdA== (base64), the lab derived 4 keys of 32 bytes. 3 of 3 password-hash settings meet the OWASP minimum:
| Function | Parameters | Memory | Key starts with |
|---|---|---|---|
| PBKDF2-HMAC-SHA-256 | 600,000 iterations | – | 406e8133… |
| scrypt | N = 2¹⁷, r = 8, p = 1 | ≈128 MiB | aefe8590… |
| Argon2id | m = 19,456 KiB, t = 2, p = 1 | ≈19 MiB | 40a1eb83… |
| HKDF-SHA-256 | info empty | – | f45780dc… |
It added the warning that HKDF does no key stretching.
Reproducing the RFC 7914 scrypt vector (password password, salt NaCl, N = 2¹⁰, r = 8, p = 16, 64 bytes) gave fdbabe1c9d347200…2cc0640, exactly the published value. The lab also flagged the setting as below the OWASP minimum and the 4-byte salt as too short. That's correct for a test vector, and a useful reminder not to copy its parameters into production.
How to read the result
- Parameters: the effective settings, with PBKDF2 iterations filled in from OWASP when you leave them empty.
- Memory: approximate RAM per derivation (128 × N × r bytes for scrypt; m KiB for Argon2id). Memory is what makes large-scale guessing expensive.
- Meets OWASP: yes or no against the cheat-sheet minimums, with the reference value shown. HKDF has no rating because it isn't a password hash.
- Key: the derived bytes in hex or base64. The same inputs always give the same key.
- Warnings: short salts, settings below the minimums, and HKDF misuse.
Tips and common mistakes
- Use a fresh random salt of at least 16 bytes for every password. Never reuse the example salts.
- Check the formats: if your salt is hex in your code, set Salt is to hex. A mismatched format is the most common reason a test vector doesn't reproduce.
- More is not always better. Tune the cost so one login takes a reasonable time on your server, then stay at or above the OWASP minimum.
- With JavaScript on, the page shows real timings for PBKDF2, HKDF and scrypt, which helps with tuning. Argon2id runs only on the server, and you're asked first.
- For real password storage, use a library that writes a PHC string (
$argon2id$v=19$m=…). It stores the algorithm, parameters and salt together with the hash.
FAQ
Which one should I choose?
OWASP lists Argon2id first, then scrypt. PBKDF2 is mainly for FIPS-constrained environments, and then with high iteration counts.
Why does PBKDF2 need 600,000 iterations?
It uses almost no memory, so attackers can run it in parallel cheaply. Iterations are its only defence. SHA-512 needs fewer (210,000) and SHA-1 more (1,300,000).
Is my password sent to the server?
Server and API runs receive it, and nothing is stored beyond the request.
Why are there no timings in the API result?
So that identical inputs always give identical results. Timings appear only with JavaScript on.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://keyderivationlab.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://keyderivationlab.usefulweb.site/mcp· tool namekey_derivation_lab
Example request
curl -s -X POST https://keyderivationlab.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"password":"correct horse battery staple","salt":"c2FsdHNhbHRzYWx0c2FsdA==","saltFormat":"base64"}'