Bcrypt Generator
Hash a password with bcrypt at the cost you choose, or check a password against any bcrypt hash.
By Syed Mubashir Ali · Last updated
Choosing a cost factor
The cost is the power of two that sets how many rounds of key setup bcrypt runs, so cost 10 means 2¹⁰ = 1,024 rounds and cost 12 means 4,096. Each step up doubles the time it takes to make or check a hash.
| Cost | Rounds | Use it for |
|---|---|---|
| 4–6 | 16–64 | Unit tests and local development only |
| 10 | 1,024 | The minimum for production |
| 12 | 4,096 | A good balance for most logins |
| 13–15 | 8,192–32,768 | Extra protection where a slower login is acceptable |
Bcrypt or a fast hash?
MD5, SHA-1 and SHA-256 produce a fingerprint of any data in microseconds. That speed is exactly what you want when you're checking that a download arrived intact, and exactly what you don't want for passwords, because an attacker with a stolen database can test guesses just as fast. Bcrypt is slow on purpose and salts every hash, which makes each guess expensive and pre-computed tables useless.
So use a fast hash for files, checksums and signatures, and bcrypt (or Argon2id) for anything a person types to log in. If you need a password to test with, make a long random one first.
- Hash Generator: MD5 and SHA checksums for files and data: the right tool for those, the wrong one for storing passwords.
- Strong Password Generator: make a long random password to hash and test with.
Reading a bcrypt hash
Every bcrypt hash is 60 characters in four parts: the version between dollar signs, the two-digit cost, 22 characters of salt and 31 characters of hash, written in bcrypt's own Base64 alphabet. Here is a real cost-12 hash of the password correct horse battery staple, made with this tool; paste both into Verify and it checks out.
$2b$12$/3cDFPGsm6LTv4gGM.ZimOQWhQyb.kLD3cLnD.7MAxFEUepN1eb02 $2b$ version (2b) 12$ cost 12, 4,096 rounds /3cDFPGsm6LTv4gGM.ZimO salt (22 characters) QWhQyb.kLD3cLnD.7MAxFEUepN1eb02 hash (31 characters)
How to Use Bcrypt Generator
- 1On Generate, type a password and pick a cost factor. 10 is selected to start with; 12 is the usual choice for production.
- 2Press Generate hash. A progress bar and timer run while it works, because a higher cost takes longer: each step up doubles the time.
- 3Copy the 60-character hash. Underneath, it's split into its parts: the version, the cost, the 22-character salt and the 31-character hash.
- 4To check a password, switch to Verify, type the password, paste the hash and press Check password. You'll see Valid or Invalid.
- 5Generate the same password twice to see two different hashes. Each has its own random salt, and both verify.
Frequently Asked Questions
What is bcrypt?
A password-hashing function published in 1999 by Niels Provos and David Mazières, built on the Blowfish cipher. Unlike MD5 or SHA-256 it's deliberately slow, and it mixes a random salt into every hash, so a leaked database is expensive to crack one guess at a time. It's one-way: a hash can't be turned back into the password. To check a login, you hash the attempt with the salt stored in the hash and compare, which is what the Verify tab does.
What's the difference between $2a$, $2b$ and $2y$?
They're labels for versions of the same algorithm. $2a$ is the original. $2b$ came from OpenBSD in 2014 after a bug in how some implementations counted passwords longer than 255 characters. $2y$ is PHP's label for its corrected implementation, added in 2011 after a bug with accented letters in its older code, whose hashes are marked $2x$. For normal passwords all three give the same result. This tool makes $2b$ hashes and checks all three, so a $2y$ hash from PHP's password_hash verifies here.
How do I choose the cost factor?
Treat 10 (1,024 rounds) as the minimum for production and 12 (4,096 rounds) as a sensible balance for most logins; OWASP's password storage guidance also asks for 10 or more. Each step doubles the work for your server and for anyone trying to crack the hashes. Time a hash on your own production server and pick the highest cost that keeps logins quick. Costs 4 to 6 are for tests only, where speed matters more than strength.
Why does the same password give a different hash every time?
Because every hash gets a new random salt, and the salt is stored inside the hash itself (the 22 characters after the cost). That's correct behaviour, not a bug: two users with the same password end up with different hashes, so cracking one doesn't reveal the other. Checking a password reads the salt back out of the stored hash, which is why every one of those different hashes still verifies.
Is there a limit on password length?
Yes. Bcrypt only reads the first 72 bytes of a password, a limit of the Blowfish key setup, and quietly ignores the rest. In UTF-8 an English letter is 1 byte, an accented letter 2 and an emoji 4, so the limit can arrive sooner than you'd expect. The byte counter above the password box warns you when you pass it. Some frameworks get round it by hashing the password with SHA-256 first, but that has to be done identically every time.
Why not hash passwords with SHA-256 or MD5?
Because they're built to be fast. A graphics card can try billions of MD5 or SHA-256 guesses a second, which is perfect for checking a file and terrible for protecting passwords. Bcrypt makes each guess slow on purpose, and the cost lets you slow it further as hardware improves. Argon2id is the newer alternative that OWASP now lists first; bcrypt remains widely supported and is fine at a sensible cost.
About Bcrypt Generator
This tool makes and checks bcrypt hashes in your browser with bcryptjs, a JavaScript implementation of bcrypt that's bundled into the page rather than loaded from another site. Once the page has loaded it works with no connection at all, and nothing you type is sent anywhere.
It's built for development and testing: making a hash for a seed file or a test account, checking that a hash in your database matches the password you think it does, or seeing how long each cost takes. Real users' passwords should be hashed on your own server, with your framework's bcrypt library, never through a website.
Passwords typed here aren't remembered. Unlike some of the site's text tools, this one has no recent-inputs list, stores nothing in your browser, and asks browsers and password managers not to save or refill its fields. Reload the page and everything is gone.