About the Bcrypt Generator
bcrypt is one of the standard ways to store passwords. Instead of saving the password itself, a website saves a bcrypt hash: a 60-character string made from the password, a random salt and a cost factor. When you sign in, the site hashes what you typed the same way and compares the results.
The Bcrypt Generator creates real bcrypt hashes with the cost factor you choose, from 4 to 15, and shows how long each cost takes on your device. The second panel checks whether a password matches an existing hash, whether it was made by PHP ($2y$), Node.js, Python or any other bcrypt library ($2a$ or $2b$).
It is handy for creating a test user, seeding a database, checking that a login bug is not a hashing bug, or learning how password hashing works. Hashing runs in your browser with bcryptjs, so neither the password nor the hash is sent anywhere.
How to use it
- Enter a passwordType it in the Password field on the left. Show reveals it so you can check for typos.
- Choose the cost factorDrag the slider from 4 to 15. The hint shows the number of rounds and how long one hash takes on this device; 10 to 12 is typical for web logins.
- Generate the hashClick Generate hash. A progress counter runs while bcrypt works, then the 60-character hash appears, ready to copy.
- Check a passwordOn the right, enter a password and paste a bcrypt hash, or click "Use the hash on the left". Then click Check password.
- Read the resultYou see whether the password matches, plus the version, the cost and the salt read from the hash.
Key features
Real bcrypt
Uses bcryptjs, a widely used implementation, so hashes work with PHP password_verify, Node.js, Python, Ruby, Java and Go libraries.
Adjustable cost
Every step up doubles the work: cost 10 is 1,024 rounds and cost 12 is 4,096. The time estimate is measured on your own device.
Random salt every time
Each hash gets a new random 16-byte salt, so the same password never gives the same hash twice.
Verify any version
Checks $2a$, $2b$ and $2y$ hashes and shows their version, cost and salt.
72-byte warning
bcrypt ignores everything after the first 72 bytes of a password. The tool warns you when a password is that long.
Private by design
Hashing and checking happen in your browser. Nothing is uploaded.
Examples
Anatomy of a bcrypt hash
Hashing "correct horse battery staple" with cost 10 gave this hash:
$2b$10$7HYLZ6qmmgDamZM30XUP7e0q5Ui3kExRbJjRlXqe3oxqSQhSBxLHK
| Part | Meaning |
|---|---|
$2b$ | The bcrypt version |
10$ | The cost: 2^10 = 1,024 rounds |
| Next 22 characters | The salt: 7HYLZ6qmmgDamZM30XUP7e |
| Last 31 characters | The hash itself |
Generate the same password again and you get a completely different string, because the salt is new each time. Both hashes still match the password.
Checking a hash made by PHP
PHP's password_hash() made this hash of the same password:
$2y$10$FE.vHYaz8KqyOuSgPNwQLuKq0mKFCbTxUkUIRfjwXmckqmreWS0Ha
Paste it with "correct horse battery staple" and the result is The password matches, with Version 2y, cost 10, salt FE.vHYaz8KqyOuSgPNwQLu. Change the first letter to a capital C and it says The password does not match. In the other direction, PHP's password_verify() accepts the $2b$ hashes this tool creates.
Cost factor and time
| Cost | Rounds | Relative time |
|---|---|---|
| 8 | 256 | ¼ of cost 10 |
| 10 | 1,024 | 1× |
| 12 | 4,096 | 4× |
| 14 | 16,384 | 16× |
On our test machine, cost 10 took about a tenth of a second in the browser and cost 12 about 0.4 seconds. The hint under the slider measures your own device, and servers running native bcrypt are usually faster. Choose the highest cost your login page can afford, often around a quarter of a second per sign-in.
Something that is not bcrypt
Paste an MD5 hash such as 5f4dcc3b5aa765d61d8327deb882cf99 and the checker says Not a bcrypt hash: a bcrypt hash is 60 characters and starts with $2a$, $2b$ or $2y$.
Tips
- In your own code, use your language's built-in password functions, such as password_hash() in PHP or the bcrypt package in Node.js. Use this tool for tests, seeds and checks.
- Store the whole 60-character string. The version, cost and salt are part of it, so you never need a separate salt column.
- Raise the cost over the years as hardware gets faster. Most libraries can detect an old cost at sign-in and rehash the password with the new one.
- If a password may be longer than 72 bytes, such as a long passphrase in a non-Latin script, consider Argon2id instead, or follow your library's advice for long passwords.
- Use a test password, not your real one, when you generate hashes for sample data or bug reports.
Common mistakes and limits
- Comparing hashes as textTwo bcrypt hashes of the same password are always different because of the salt. Check a password with a verify function, never by generating a new hash and comparing strings.
- Using MD5 or SHA-256 for passwordsFast hashes can be tried billions of times per second. bcrypt is slow on purpose, which is what makes stolen password hashes hard to crack.
- Choosing a very high costEach step doubles the time. Cost 15 can take several seconds per sign-in, which slows your site and makes it easier to overload with login attempts.
- Ignoring the 72-byte limitCharacters after the first 72 bytes do not change the hash, so two long passwords that start the same way would both match. Accented letters and emoji use 2 to 4 bytes each.
- Thinking a hash can be reversedbcrypt cannot be decoded. Tools that claim to "decrypt" bcrypt are guessing passwords one by one.