BcryptGenerator.org
By Shahzeb Zafar··Updated ·8 min read

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.

bcryptpassword hashingsecurity

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:

  1. Generate a salt. Bcrypt creates 16 random bytes for every new hash.
  2. 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.
  3. Encrypt a fixed string. It uses the resulting cipher state to encrypt the constant text "OrpheanBeholderScryDoubt" 64 times.
  4. Pack everything into one string. The version, cost, salt and result are combined into the 60-character hash you store.
Diagram of how bcrypt works. Hashing: the password and a random 16-byte salt go through an expensive Blowfish key setup repeated 2 to the power of cost times, then encrypt OrpheanBeholderScryDoubt 64 times, and are packed into a 60-character string of version, cost, salt and hash. Checking at login: read the cost and salt from the stored hash, re-run the same steps on the typed password and compare; nothing is decrypted.

Reading the example hash from left to right:

PartExampleMeaning
Version$2b$Which revision of bcrypt ($2a$, $2b$ or $2y$)
Cost12Work factor: 2¹² = 4,096 rounds of key setup
SaltRB2qR6GI4quP.PUs6xR5He22 characters encoding the random 16-byte salt
Hash37dCyunLcYFzlvUfwSX41XkRXgOQ3OS31 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

AlgorithmDesigned for passwordsSalt built inSpeedUse for passwords?
MD5NoNoVery fastNever
SHA-256NoNoVery fastNot on its own
SHA-256 + saltNoManualVery fastNot recommended
PBKDF2YesYesTunable (iterations)Yes, mainly where FIPS compliance is required
BcryptYesYesSlow by designYes
Argon2idYesYesTunable (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.