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
| Output | 192 bits in a 60-character ASCII format $2b$… |
|---|---|
| Cost | Single log2 work factor (cost), typically 10-12 in 2026 |
| Internal primitive | Blowfish expensive key schedule (EksBlowfish) |
| Memory hard? | No (~4 KiB per attempt) |
| Password length limit | 72 bytes (Blowfish key size) |
| Standard | None formal; Provos & Mazières USENIX 1999 |
| Status | Battle-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
- OpenBSD , where it originated.
- Linux
crypt(3),$2y$/$2b$identifiers. - Rails, Django, Laravel, Spring , default password hashers for years.
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.
Q1.Year bcrypt was published:
Q2.Underlying primitive:
Q3.bcrypt's maximum password length:
Q4.bcrypt cost factor scaling:
Q5.Is bcrypt memory-hard?
Q6.Canonical 2026 prefix in encoded bcrypt hash:
Q7.Workaround for long passwords with bcrypt:
Q8.Recommended cost in 2026:
Q9.Where does bcrypt store its salt?
Q10.Which Wikipedia category?