deftools.io Security

🔒 Bcrypt Generator

Hash a password with bcrypt — pick the cost factor and salt rounds, or verify a password against an existing bcrypt hash.

About this tool

Bcrypt is a password hashing function designed specifically for storing credentials. It is slow on purpose: the cost factor (also called rounds) controls how many iterations the algorithm runs, so you can keep raising it as hardware gets faster. Every hash also carries a random salt, so two identical passwords produce completely different hashes. Unlike plain SHA-256, bcrypt is resistant to brute-force and rainbow-table attacks.

Example: hashing correct horse battery staple at cost 12 with the 2b variant produces a string like $2b$12$LJ3m4ys3Lg8.vKq1m2ZB9u5J3fQ1…. The format is $2b$ + cost + $ + 22-char salt + 31-char hash. Store the whole string in your database — you do not need a separate salt column.

Use the Verify tab to check whether a plaintext password matches an existing hash. This is how a login flow works: re-hash the submitted password against the salt embedded in the stored hash and compare.

FAQ

What cost factor should I use?

Aim for roughly 250–500 ms per hash on your production hardware. Cost 12 is a reasonable starting point on modern servers (~300 ms). Each +1 doubles the work — cost 14 takes ~4× as long as cost 12. Re-evaluate once a year and raise it if logins feel too fast.

What is the difference between $2a$, $2b$, and $2y$?

They are versions of the same algorithm. $2b$ is the current standard and fixes an old length-overflow bug in the original $2a$. $2y$ is the identifier PHP's crypt() emits; it behaves identically to $2b$. In practice all three produce hashes that verify against each other in most libraries.

Do I need to store the salt separately?

No. The salt is embedded inside the hash string itself (the 22 characters after the second $). To verify a password you pass both the password and the full stored hash to bcrypt — it extracts the salt and cost automatically.

Is bcrypt better than SHA-256 for passwords?

Yes, for password storage. SHA-256 is a fast general-purpose hash — an attacker with a GPU can try billions of SHA-256 guesses per second. Bcrypt is deliberately slow and memory-hard enough to make offline cracking of a stolen hash database impractical. Use SHA-256 for file integrity and signatures, bcrypt (or argon2) for user passwords.

Related security tools

Copied!