Glossary Security

bcrypt

bcrypt is a deliberately slow password-hashing function that adds a random salt and a tunable cost factor, so stolen password hashes are expensive to crack.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page

In more detail

bcrypt hashes a password with a random Salt and repeats an expensive key-setup step 2 to the power of the cost factor times. A hash looks like $2b$12$ followed by a 22-character salt and the hash, 60 characters in all; the 12 is the cost, so 4,096 rounds. Raising the cost by one doubles the work, which lets defenders keep pace with faster hardware. The algorithm only reads the first 72 bytes of a password.

Why it matters

General-purpose hashes such as SHA-256 are designed to be fast, which helps attackers who test billions of guesses per second against a stolen database. bcrypt's slowness and built-in salt make each guess costly and stop identical passwords producing identical hashes. It is one of the standard choices for storing passwords, alongside newer functions such as scrypt and Argon2.

Example

Create and verify bcrypt hashes with the Bcrypt Generator. Hashing the same password twice produces two different strings, because each has its own salt, yet both verify correctly.

Common confusion

bcrypt is a password-hashing function, not an encryption method: it cannot be reversed. It is also not a replacement for a long, unique password, because a weak password is still guessed quickly even with a high cost.

AdSense Placeholder
Slot: footer_leaderboard