What is Bcrypt? How It Works and What It Is Used For
Bcrypt is a slow, salted password hash. See how bcrypt works step by step in one diagram, what it is used for, and whether it is still secure in 2026.
Bcrypt is a password-hashing function: it turns a password into a fixed-length string that can be stored safely and checked later, but can't be turned back into the password. It was designed by Niels Provos and David Mazières and published in 1999. Two features make it suited to passwords: it is deliberately slow, and it adds a random salt to every hash.
A bcrypt hash looks like this. This one is a real hash of correct horse battery staple, so you can check it with the bcrypt checker:
$2b$12$RB2qR6GI4quP.PUs6xR5He37dCyunLcYFzlvUfwSX41XkRXgOQ3OS
What does "bcrypt" mean?
The name combines Blowfish, the block cipher bcrypt is built on, with crypt, the traditional Unix function for hashing passwords. Bcrypt began as the password scheme of the OpenBSD operating system and is now available in practically every programming language.
What is bcrypt used for?
Bcrypt is used almost exclusively for storing passwords. When someone creates an account, the application stores the bcrypt hash of their password instead of the password itself. When they log in, the application checks the password they typed against that hash.
That way, if the database is ever leaked, attackers don't get anyone's actual password. They get hashes they would have to crack one guess at a time.
You'll find bcrypt as the default or recommended option in many frameworks: PHP's password_hash(), Laravel, Ruby on Rails' has_secure_password, Spring Security's BCryptPasswordEncoder, and the bcrypt and bcryptjs packages for Node.js.
Bcrypt is not the right tool for:
- Encrypting data you need to read back. Bcrypt is one-way. Use encryption such as AES for that.
- Checksums and file integrity. Use a fast hash such as SHA-256.
- API keys and tokens that are checked on every request. Bcrypt's slowness adds latency to each call. A fast keyed hash (HMAC) is the usual choice there.
How does bcrypt work?
Bcrypt hashing happens in four steps:
- Generate a salt. Bcrypt creates 16 random bytes for every new hash.
- Run the expensive setup. It sets up the Blowfish cipher using the password and the salt, then repeats that key setup 2^cost times. This repeated setup, known as "Eksblowfish" (expensive key schedule Blowfish), is what makes bcrypt slow.
- Encrypt a fixed string. It uses the resulting cipher state to encrypt the constant text "OrpheanBeholderScryDoubt" 64 times.
- Pack everything into one string. The version, cost, salt and result are combined into the 60-character hash you store.
Reading the example hash from left to right:
| Part | Example | Meaning |
|---|---|---|
| Version | $2b$ | Which revision of bcrypt ($2a$, $2b$ or $2y$) |
| Cost | 12 | Work factor: 2¹² = 4,096 rounds of key setup |
| Salt | RB2qR6GI4quP.PUs6xR5He | 22 characters encoding the random 16-byte salt |
| Hash | 37dCyunLcYFzlvUfwSX41XkRXgOQ3OS | 31 characters encoding the result |
Because the salt and cost are stored inside the hash, you only ever store one value per user.
How is a password checked?
Checking is the same process run again. The library reads the version, cost and salt from the stored hash, hashes the password that was typed with exactly those settings, and compares the two results. If they match, the password is correct. Nothing is ever decrypted.
Why does bcrypt use a salt?
Without a salt, everyone with the password password123 would have the same hash. An attacker could precompute hashes for millions of common passwords once and look up every match instantly (a "rainbow table" attack).
The random salt makes every hash unique, even for identical passwords. That's why hashing the same password twice gives two different results, and both still verify. Precomputed tables become useless, because the attacker would need a separate table for every salt.
Why is bcrypt slow, and why is that good?
Speed is exactly what you don't want in a password hash. General-purpose hashes like MD5 and SHA-256 are built to be fast, and that helps attackers: they can try enormous numbers of guesses against a stolen hash.
The numbers show the scale. In October 2022, security researcher Sam Croley reported benchmarking an overclocked RTX 4090 with hashcat at about 300 billion NTLM hashes per second (NTLM is a fast hash, like MD5), but only about 200,000 bcrypt hashes per second (TechSpot). Bcrypt was over a million times slower to attack on the same hardware, and every extra cost point halves the attacker's speed again.
For your own server, a bcrypt check at a sensible cost takes a fraction of a second. That's barely noticeable at login, which happens rarely, but it adds up fast for someone testing billions of guesses.
The cost factor also lets bcrypt keep pace with hardware. When computers get faster, you raise the cost by one and the work doubles. See how many bcrypt rounds to use for choosing a value.
Is bcrypt encryption?
No. Encryption is two-way: with the right key, you get the original data back. Bcrypt is a one-way hash, so there's no key and no way to turn a hash back into a password. The only way to recover a password from a bcrypt hash is to guess it and check each guess, which bcrypt makes deliberately slow. See can you decrypt a bcrypt hash? for what to do instead.
Is bcrypt still secure in 2026?
Yes, when it's used properly. There are no known practical attacks against bcrypt itself, and OWASP's Password Storage Cheat Sheet still lists it as acceptable with a work factor of at least 10. We recommend 12 for new hashes.
Two caveats are worth knowing:
- Newer options exist. OWASP now recommends Argon2id first for new systems, and bcrypt for systems where Argon2id isn't available. Argon2id also makes attackers pay in memory, not just computation. See bcrypt vs Argon2.
- The 72-byte limit. Bcrypt only uses the first 72 bytes of a password. Some libraries silently ignore the rest, and newer ones reject longer passwords. See bcrypt's maximum password length for how to handle it.
Bcrypt compared with other hashes
| Algorithm | Designed for passwords | Salt built in | Speed | Use for passwords? |
|---|---|---|---|---|
| MD5 | No | No | Very fast | Never |
| SHA-256 | No | No | Very fast | Not on its own |
| SHA-256 + salt | No | Manual | Very fast | Not recommended |
| PBKDF2 | Yes | Yes | Tunable (iterations) | Yes, mainly where FIPS compliance is required |
| Bcrypt | Yes | Yes | Slow by design | Yes |
| Argon2id | Yes | Yes | Tunable (memory and time) | Yes, OWASP's first choice |
Try it
Use the bcrypt generator to create a hash, then paste it into the bcrypt checker with the same password. Hash the same password twice and you'll see the salt at work: two different hashes, and both verify. For code, see the Node.js, PHP and Python guides.
Ready to try it?
Open Bcrypt Generator →Related Articles
bcrypt vs bcryptjs: Which Should You Use in Node.js?
We benchmarked bcrypt 6 and bcryptjs 3 on Node 24: one login takes about the same time, eight at once differ 4x. Results, install facts and which to use.
Bcrypt Hash Length: How to Store It in MySQL and PostgreSQL
A bcrypt hash is always 60 characters. Learn the right column type for MySQL and PostgreSQL, why VARCHAR(50) breaks logins, and how to fix a truncated column.
Can You Decrypt a Bcrypt Hash? No, and Here Is What Works Instead
Bcrypt hashes can't be decrypted, online or with the salt. See what "bcrypt decrypt" sites really do, and how to check, reset or migrate passwords instead.