What is bcrypt?
bcrypt is a password-hashing function that turns a password into a salted, deliberately slow hash so stolen databases are hard to crack. It was described by Niels Provos and David Mazières in 1999, and OWASP lists it alongside Argon2id and PBKDF2 as an acceptable way to store passwords, though it recommends Argon2id first (OWASP).
Websites should never store your password itself. They store a hash, a one-way fingerprint, and compare it to the hash of what you type. Fast hashes such as SHA-256 are poor for this job because attackers can test huge numbers of guesses quickly. bcrypt is built to be slow. For the general idea, see what hashing is and the bcrypt glossary entry.
How bcrypt works
- A unique salt per password. OWASP explains that a salt is a unique random value added to each password, so an attacker must crack hashes one at a time and cannot use precomputed rainbow tables. Two users with the same password end up with different hashes (OWASP). See salted password hash.
- A tunable work factor. The work factor sets how many iterations are performed, usually 2 to the power of the work value, and it is stored in the hash output. Raising it makes each guess more expensive for an attacker.
- Verification by recomputing. At login, the site reads the salt and work factor from the stored hash, hashes the password you typed the same way and compares the results.
The original paper, “A Future-Adaptable Password Scheme,” argued that password hashing should be able to get slower as computers get faster, which is why the work factor exists (Provos and Mazières, 1999).
Get the free 5-minute weekday brief
Scam alerts you can act on, major breaches, and our free Scam Survival Kit (PDF). Free, every weekday.
By subscribing you agree to our Privacy Policy.
For everyday readers, small businesses and security teams. Unsubscribe anytime.
bcrypt vs. Argon2id, scrypt and PBKDF2
OWASP’s current minimums, which it says to treat as starting points to tune for your hardware (OWASP):
| Algorithm | OWASP guidance |
|---|---|
| Argon2id | First choice. Minimum of 19 MiB memory, 2 iterations and 1 degree of parallelism |
| scrypt | If Argon2id is not available. Minimum cost parameter of 2^17, block size 8 and parallelism 1 |
| bcrypt | For legacy systems. Work factor of 10 or more, with a password limit of 72 bytes |
| PBKDF2 | If FIPS-140 compliance is required. Work factor of 600,000 or more with HMAC-SHA-256 |
Argon2 is a memory-hard function, specified in RFC 9106 for password hashing and proof-of-work, which makes large-scale guessing on specialized hardware more expensive (RFC 9106). OWASP also advises that, as a general rule, computing a password hash should take under one second on your server.
The 72-byte limit
OWASP notes bcrypt’s password limit of 72 bytes. Very long passphrases, or passwords with many multi-byte characters, can be affected. If you build a system on bcrypt, follow your library’s guidance on long passwords and test it. If you are starting fresh, OWASP’s order of preference puts Argon2id first.
What NIST says
NIST SP 800-63B-4, the U.S. digital identity guideline, says verifiers must store passwords salted and hashed using a suitable password-hashing scheme that resists offline attacks, with a salt of at least 32 bits, and that the cost factor should be as high as practical without hurting performance (NIST SP 800-63B-4).
What hashing does not protect you from
- Weak or reused passwords. A slow hash makes guessing costly, but a common password is still guessed early. Use a password manager and read our password policy best practices.
- Phishing. If someone tricks you into typing a password into a fake page, no hash helps. Passkeys avoid shared secrets altogether.
- Malware or a stolen session. Hashes protect the stored database, not a compromised device.
- Missing second factor. Add multi-factor authentication wherever it is offered.
You cannot see how a site hashes your password, but you can limit the damage of any breach: use unique passwords, turn on two-factor, and act quickly after a notice with our data breach checklist. Developers can read about Argon2 for the newer option.
Frequently asked questions
Is bcrypt still secure?
OWASP lists bcrypt as an acceptable choice, especially for legacy systems, with a work factor of 10 or more and a 72-byte password limit. It recommends Argon2id first. Source: OWASP.
What is a work factor?
It is the number of iterations the hash performs, usually 2 to the power of the work value, which controls how slow each guess is. Source: OWASP.
bcrypt or Argon2id: which should I use?
OWASP recommends Argon2id as the first choice, and bcrypt for legacy systems. Source: OWASP.
Why not just use SHA-256 for passwords?
OWASP says fast algorithms such as SHA-256 are not suitable for password storage because they allow attackers to try many guesses quickly. Source: OWASP.
Does bcrypt include a salt?
Yes. The scheme uses a unique salt for each password, and the salt and work factor are stored in the hash output. Sources: OWASP, Provos and Mazières.
Can attackers decrypt a bcrypt hash?
A hash is one-way, so there is nothing to decrypt. Attackers instead guess passwords, hash each guess and compare. A slow hash and a unique password make that impractical.
Sources
- OWASP: Password Storage Cheat Sheet
- Provos and Mazières: A Future-Adaptable Password Scheme (USENIX 1999)
- IETF RFC 9106: Argon2 Memory-Hard Function for Password Hashing and Proof-of-Work Applications
- NIST SP 800-63B-4: Digital Identity Guidelines, Authentication and Authenticator Management
Start your morning with the signal that matters.
Get the biggest cybersecurity developments, why they matter, and where to go deeper on CyberExperts.
By subscribing you agree to our Privacy Policy.
For everyday readers, small businesses and security teams. Unsubscribe anytime.