Bcrypt hash generator for password storage
Bcrypt is a password hashing function designed in 1999 by Niels Provos and David Mazières. Unlike general-purpose hashes such as MD5 or SHA-256, which are built to be fast, a bcrypt hash is deliberately slow and salted, so attackers who steal a database cannot test billions of guesses per second. This generator creates standard $2y$ bcrypt hashes in your browser, ready for PHP, Laravel, Symfony, WordPress plugins, Node.js, Python, Go and most other platforms.
Typical, legitimate uses are seeding test or demo users, writing database fixtures, and resetting the password of an admin account in an application you operate when the normal reset flow is unavailable.
Example
Hashing correct horse battery staple with cost 10 produced:
$2y$10$oQUDqqYCDyDhbXPZRluK8OwRGLK4lYR4ZF4Csglsl4UODRXIvGUFiHashing the same password again gives a different string, such as $2y$10$0iNESMe2IAVzDcfSF.kcXufDc.t1.SFj0B8YKf3trBqGKhgqnY6vm. Both are correct: each hash contains its own random salt, and verification reads the salt from the hash.
Anatomy of a bcrypt hash
| Part | Example | Meaning |
|---|---|---|
| Prefix | $2y$ | Algorithm version |
| Cost | 10$ | log₂ of the number of key-expansion rounds (2¹⁰ = 1,024) |
| Salt | oQUDqqYCDyDhbXPZRluK8O | 22 characters = 128 random bits, in bcrypt’s own Base64 alphabet |
| Hash | wRGLK4lYR4ZF4Csglsl4UODRXIvGUFi | 31 characters = 184 bits of the result |
The whole string is always 60 characters long, so a VARCHAR(60) column is enough for bcrypt itself — although many frameworks recommend 255 so you can switch to longer formats such as Argon2 later.
Choosing the cost factor
The cost factor controls how slow each hash is, and each step up doubles the work. On a typical server, cost 10 takes on the order of 50–100 ms per hash, cost 12 about four times as long. Higher cost makes stolen hashes much harder to crack but also makes every login slower and uses more CPU.
- OWASP’s Password Storage Cheat Sheet recommends a work factor of at least 10 for bcrypt.
- PHP’s password_hash() used cost 10 by default until PHP 8.4, which raised the default to 12; Laravel’s default is also 12 in recent versions.
- Aim for a value that takes a few hundred milliseconds at most on your production hardware, and raise it over time as hardware gets faster. Frameworks can rehash on the next successful login.
- Costs 4–9 are only sensible for automated tests, where speed matters more than strength.
Because this tool runs in your browser, high costs such as 14 can take several seconds on slower devices.
$2a$, $2b$ and $2y$
All three prefixes denote bcrypt. $2a$ is the original. $2y$ was introduced by PHP in 2011 after a bug in one implementation’s handling of non-ASCII characters, to mark hashes from the corrected code; $2b$ is OpenBSD’s 2014 fix for a different bug with very long passwords. For correctly implemented libraries, the three produce the same result, and most verifiers accept all of them. This tool outputs $2y$, the format of PHP’s password_hash().
Limits and good practice
- 72-byte limit. Bcrypt only uses the first 72 bytes of the password; the rest is ignored. With UTF-8, non-Latin characters take several bytes each, so the limit is reached sooner. Some systems (including WordPress 6.8) pre-hash passwords to work around this.
- Never use MD5, SHA-1 or plain SHA-256 for passwords. They are far too fast. Bcrypt, Argon2id, scrypt or PBKDF2 with a high iteration count are the appropriate choices; OWASP lists Argon2id first for new systems.
- Hash on the server in production. Your application should hash passwords with its own library at sign-up and login. Use this tool for fixtures, test data and administrative one-offs.
- Bcrypt is one-way. A hash cannot be decrypted; it can only be checked against a candidate password.
Privacy
The password and hash are computed locally with WebAssembly and a salt from your browser’s secure random generator; nothing is sent to our server. To test a password against an existing hash, use the Bcrypt Hash Checker. For WordPress sites, the WordPress Password Hash Generator produces the exact format WordPress expects, and the Password Generator can create a strong password to hash.