Hash Lab

Password hashing / KDF

bcrypt

A password hashing function built on the Blowfish cipher’s deliberately expensive key schedule. Designed by Niels Provos and David Mazières (USENIX 1999). bcrypt was the first widely-deployed password hash with a tunable cost factor; twenty-five-plus years later it’s still a fine choice when memory-hardness isn’t required.

At a glance

Output192 bits in a 60-character ASCII format $2b$…
CostSingle log2 work factor (cost), typically 10-12 in 2026
Internal primitiveBlowfish expensive key schedule (EksBlowfish)
Memory hard?No (~4 KiB per attempt)
Password length limit72 bytes (Blowfish key size)
StandardNone formal; Provos & Mazières USENIX 1999
StatusBattle-tested; prefer Argon2id for new designs

How the cost factor works

The cost parameter is a log2 value. Cost 10 means 210=1024 internal key-schedule iterations; cost 12 means 4096. Each increment doubles the time. Calibrate so an interactive login takes ~250 ms on the target hardware; bump every couple of years. bcrypt hashes embed the cost in the encoded string, so verification automatically uses the same cost.

The 72-byte limit

bcrypt is built on Blowfish, whose key size is at most 72 bytes. Inputs longer than 72 bytes are silently truncated. The standard mitigation is to pre-hash long inputs with SHA-256 / HMAC-SHA-256 and feed the digest to bcrypt:

bcrypt.hash(base64(hmac_sha256(pepper, password)), cost=12)

Not memory-hard

bcrypt only allocates ~4 KiB per attempt. That was a big number in 1999; today a single GPU has tens of GB of RAM and can run thousands of bcrypt attempts in parallel. For high-stakes password storage in new designs, prefer Argon2id.

Where it is used

The $2a$ / $2y$ / $2b$ story

Multiple prefixes exist because of historical sign-extension bugs.$2b$ is the current canonical identifier; $2y$is a PHP-specific fix; $2a$ is the original. For verification, treat all three as bcrypt; for new hashes, write$2b$.

References

Generate

Run bcrypt on your input

16 bytes

10

Quick quiz

Test yourself on bcrypt

10 multiple-choice questions. Pick an answer for each, then submit to see explanations.

  1. Q1.Year bcrypt was published:

  2. Q2.Underlying primitive:

  3. Q3.bcrypt's maximum password length:

  4. Q4.bcrypt cost factor scaling:

  5. Q5.Is bcrypt memory-hard?

  6. Q6.Canonical 2026 prefix in encoded bcrypt hash:

  7. Q7.Workaround for long passwords with bcrypt:

  8. Q8.Recommended cost in 2026:

  9. Q9.Where does bcrypt store its salt?

  10. Q10.Which Wikipedia category?

0 of 10 answered