What bcrypt is
Bcrypt is a password hashing function designed by Niels Provos and David Mazières and published in 1999. Unlike MD5 or SHA-256, it is meant to be slow. A cost setting decides how much work each hash takes, and every step up doubles it. That barely matters when one user logs in, but it makes trying millions of guesses very expensive.
Bcrypt also adds a random salt to every password. Two users with the same password get different hashes, so an attacker cannot use precomputed tables or crack many accounts at once.
The hash format
A bcrypt hash is 60 characters long and carries everything needed to check a password:
The versions $2a$, $2b$ and $2y$ differ only in how old implementations handled rare edge cases. Modern libraries accept all three.
Choosing a cost
| Cost | Rounds | Work compared with cost 10 |
|---|---|---|
| 8 | 256 | 1/4 |
| 10 | 1,024 | 1× |
| 12 | 4,096 | 4× |
| 14 | 16,384 | 16× |
Use the highest cost your login server can handle comfortably, and raise it every few years as hardware gets faster. Our article on hashing passwords correctly covers the alternatives, such as Argon2 and scrypt.
Questions about bcrypt
Why does the same password give a different bcrypt hash every time?
Bcrypt adds a random 128-bit salt before hashing and stores that salt inside the hash. Two hashes of the same password therefore look different, yet both verify, because the checker reads the salt back out of the hash.
What cost should I use?
Pick the highest cost your server can afford for each login. Many frameworks default to 10 or 12. Each step up doubles the work, so cost 12 takes four times as long as cost 10. The timing next to the hash shows how long it took in your browser.
Are these hashes compatible with PHP, Node.js and other languages?
Yes. This page uses bcryptjs, a standard bcrypt implementation. We checked that its hashes verify with PHP's password_verify and that PHP hashes verify here. The $2y$ prefix used by PHP and the $2a$ and $2b$ prefixes are treated the same.
Can a bcrypt hash be decrypted?
No. Like any hash it is one-way. The only attack is guessing passwords and hashing each guess, and bcrypt is designed to make every guess slow.
Is there a length limit?
Bcrypt uses only the first 72 bytes of a password and ignores the rest. The tool warns you when a password is longer.
Is my password sent to a server?
No. Hashing and checking run in your browser with JavaScript, and the password never leaves your device.