Home › Developer Tools › PBKDF2 Hash Generator

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:

Presets:
Enter a password to derive a key.
Advertisement
Advertisement

How to use the PBKDF2 Hash Generator

  1. Enter the password as plain text (encoded as UTF-8) or switch to Hex for raw bytes.
  2. Set the salt: keep the random 16-byte salt, press New random salt, or type your own as text, hex or Base64.
  3. 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).
  4. Press Generate key (it also updates as you type) and copy the hex, Base64 or encoded string you need.
  5. To check a stored value, paste it into Expected key: the tool tells you whether it matches.
  6. 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:

  1. 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.
  2. 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).
  3. Iterate: Uj = HMAC(P, Uj−1) for j = 2 … c.
  4. Fold: Ti = U1 ⊕ U2 ⊕ … ⊕ Uc (bitwise XOR of every round).
  5. 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-SHA120 bytes (160 bits)1,300,00020 bytes
HMAC-SHA25632 bytes (256 bits)600,00032 bytes
HMAC-SHA51264 bytes (512 bits)210,00064 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

SourceInputsDerived key (hex)
RFC 6070HMAC-SHA1, P = “password”, S = “salt”, c = 1, dkLen = 200c60c80f961f0e71f3a9b524af6012062fe037a6
RFC 6070HMAC-SHA1, P = “password”, S = “salt”, c = 4096, dkLen = 204b007901b765489abead49d926f721d065a429c1
Common SHA-256 vectorHMAC-SHA256, P = “password”, S = “salt”, c = 1, dkLen = 32120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b
Common SHA-256 vectorHMAC-SHA256, P = “password”, S = “salt”, c = 4096, dkLen = 32c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a
IEEE 802.11i (WPA2)HMAC-SHA1, passphrase “password”, SSID “IEEE”, c = 4096, dkLen = 32f42c6fc52df0ebef9ebb4b90b38a5f902e83fe1b135a70e23aed762e9710a12e

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.

Related tools

Argon2 Hash GeneratorHash passwords with Argon2id, Argon2i or Argon2d and verify them against an encoded hash.Bcrypt Hash Generator & CheckerCreate bcrypt password hashes and check a password against a hash.HMAC GeneratorGenerate and verify HMAC signatures with SHA-256, SHA-512, SHA-1 or MD5.Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes of text or files.Password GeneratorCreate strong passwords and passphrases.MD5 Hash GeneratorGenerate MD5 hashes of text, lines or files and verify checksums.SHA-256 Hash GeneratorSHA-256 and HMAC-SHA256 hashes of text, lines or files, in hex or Base64.Base64 Encoder DecoderEncode or decode Base64 text and files, and make data URIs.URL Encoder DecoderPercent-encode or decode URLs, query strings and form data.HTML Entity Encoder / DecoderEscape and unescape HTML entities, named or numeric.Binary TranslatorConvert text to binary, hex, octal and back.CRC32 Checksum CalculatorCalculate CRC-32, CRC-32C, CRC-16 and Adler-32 checksums of text or large files.JWT DecoderDecode JSON Web Tokens, read the claims and expiry, and verify HS256 signatures.JWT GeneratorCreate and sign HS256, HS384 or HS512 JSON Web Tokens in your browser and verify them.Password Strength CheckerSee how strong a password really is, how long it takes to crack and how to improve it.Caesar CipherEncode and decode Caesar shift ciphers and crack unknown shifts with a ranked brute force.Vigenère CipherEncrypt and decrypt Vigenère and Autokey ciphers, and crack unknown keys with frequency analysis.Atbash CipherEncode and decode Atbash ciphers (A↔Z, B↔Y) in Latin or Hebrew, with a live letter mapping table.ASCII TableFull ASCII code chart 0–255 in decimal, hex, octal, binary and HTML, with search and copy.Unicode Character LookupFind Unicode characters by name or code point and copy them with UTF-8, HTML and code escapes.Punycode ConverterConvert international domain names, emails and URLs between Unicode and xn-- Punycode, in bulk.JSON Escape / UnescapeEscape text for a JSON string, unescape \n and \" back to text, or stringify a whole object.Binary to HexConvert binary to hex instantly with steps and signed mode.Hex to BinaryConvert hex to binary instantly with steps and signed mode.Binary CalculatorAdd, subtract, multiply, divide, AND, OR, XOR and shift binary numbers with decimal values.Hex CalculatorHexadecimal + − × ÷ and AND, OR, XOR, NOT, shifts with decimal and binary equivalents.Base32 Encoder / DecoderEncode and decode Base32 (RFC 4648), Base32hex, Crockford and z-base-32 from text, hex or files.Base58 Encoder / DecoderEncode and decode Base58 and Base58Check (Bitcoin alphabet) from text or hex, with checksum verification.Unicode Escape / UnescapeConvert text to \uXXXX, \u{...}, \x, &#...; or CSS escapes and decode them back.File Hash CheckerGet MD5, SHA-1, SHA-256 and SHA-512 checksums of files and verify them against a hash.TOTP GeneratorGenerate 2FA one-time codes from a secret key, create otpauth QR codes and verify codes.RSA Key GeneratorGenerate 2048, 3072 or 4096-bit RSA key pairs as PEM, PKCS#1, JWK or OpenSSH, locally.SSL Certificate DecoderDecode PEM SSL/X.509 certificates: subject, issuer, expiry, SANs, key and fingerprints.Text Encryption ToolEncrypt and decrypt text with a password using AES-256-GCM, entirely in your browser.Base64 to PDFDecode a Base64 string to a PDF with preview and download, or encode a PDF to Base64.Bitwise CalculatorCalculate AND, OR, XOR, NOT and bit shifts at 8–64 bits with a bit grid and all bases.CSR GeneratorCreate a certificate signing request (CSR) and private key with SANs, RSA or ECDSA, in your browser.MongoDB ObjectId to TimestampDecode a MongoDB ObjectId to its creation date, or build ObjectIds from dates for range queries.Pwned Password CheckerCheck if a password appeared in data breaches; only 5 characters of its SHA-1 hash are sent.RSA Encryption ToolEncrypt text with an RSA public key and decrypt it with the private key using RSA-OAEP in your browser.SAML DecoderDecode SAMLRequest and SAMLResponse messages to readable XML, attributes and validity times.SSL Certificate ConverterConvert SSL certificates and keys between PEM, DER, PFX/P12 and P7B in your browser.Checksum CalculatorCompute 8-bit sum, two's complement LRC, XOR/BCC, NMEA, Fletcher and Internet checksums of bytes.Protobuf DecoderDecode raw Protocol Buffers hex or Base64 without a schema, or add a .proto for field names.XML Escape / UnescapeEscape & < > " ' for XML text and attributes, unescape entities back, or wrap text in CDATA.Binary Search Tree VisualizerInsert, delete and find in BST, AVL and red-black trees with animated rotations and traversals.PGP Encrypt / DecryptEncrypt, decrypt, sign and verify PGP messages with your armored keys, entirely offline.PGP Key GeneratorGenerate an OpenPGP key pair (Curve25519, NIST ECC or RSA) with passphrase and expiry, offline.Quoted-Printable Encoder / DecoderEncode or decode quoted-printable email text (MIME) with UTF-8 and 76-character soft line breaks.Self-Signed Certificate GeneratorCreate a self-signed SSL certificate and key for localhost or dev servers, as PEM or PFX.SHA-1 Hash GeneratorSHA-1 and HMAC-SHA1 of text or files in hex or Base64, plus Git blob hashes and verify.SHA-512 Hash GeneratorSHA-512 and SHA-384 hashes of text or files in hex or Base64, HMAC and hash verification.SRI Hash GeneratorCreate Subresource Integrity hashes (sha256/384/512) and ready <script> or <link> tags.SSH Key GeneratorGenerate Ed25519 or RSA SSH key pairs in your browser: OpenSSH public key plus private key.String Escape / UnescapeEscape or unescape strings for JavaScript, Java, C#, Python, C, SQL, regex, CSV and shell.UTF-8 Encoder / DecoderConvert text to UTF-8 bytes in hex, decimal, binary, \x or % and decode bytes back to text.UUID Decoder & ValidatorDecode any UUID: version, variant, v1/v6/v7 timestamp and MAC node, plus bulk validation.Base64 to FileDecode Base64 or a data URI to a downloadable file; detects the real file type and previews it.File Encryption ToolEncrypt and decrypt any file with a password using AES-256-GCM, entirely in your browser.Passphrase GeneratorMake strong, memorable diceware passphrases from a 7,776-word list, with entropy in bits.CSR DecoderDecode a PEM certificate signing request: subject, SANs, key size, signature and CA readiness checks.Enigma Machine SimulatorEncrypt and decrypt with a virtual Enigma I, M3 or M4: rotors, rings, plugboard and lampboard.Hex Opacity CalculatorConvert opacity percent to a 2-digit HEX alpha code and full #RRGGBBAA color, with a 0-100% table.Playfair CipherEncrypt and decrypt Playfair ciphers from a keyword, with the 5x5 key square and every digraph step.
See all 65 Encoders, Hashes & Crypto →