Reading — step 1 of 5
Read
~1 min readModern Hashes
bcrypt
Niels Provos's 1999 algorithm. Based on the Blowfish cipher's expensive key schedule.
Format: $2b$<cost>$<22-char-salt><31-char-hash>
$2b$12$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
| | |--------salt--------||----------hash----------|
ver cost
2bis the version. Older$2a$and$2$exist but$2b$is current.costislog2(iterations). Cost 12 = 4096 iterations.- 22 chars salt + 31 chars hash, both base64-ish (modified alphabet).
Cost 10 takes ~10ms on modern hardware. Cost 12 takes ~250ms (industry default). Each cost increment doubles the work.
bcrypt has been BATTLE-TESTED for 25 years. Used by countless web apps. Built into PHP, Ruby (bcrypt-ruby), Node (bcrypt), Python (bcrypt).
Limitations:
- Truncates passwords at 72 BYTES (limitation of Blowfish key schedule)
- Not memory-hard (vulnerable to GPU attacks at high parallelism)
For new code, prefer argon2id. For legacy systems with bcrypt: keep using it, just bump the cost over time.
python
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…