Bcrypt Generator & Verifier
Hash passwords with bcrypt and verify passwords against existing hashes. Processing done server-side with PHP's password_hash().
Frequently Asked Questions
password_verify($password, $hash) does this automatically. Never compare bcrypt hashes with === or string comparison functions — always use the library's built-in constant-time verify function to prevent timing attacks.===, strcmp) return early as soon as they find a mismatch — the comparison takes measurably less time for incorrect values that differ at the first character. By measuring thousands of response times, an attacker can statistically determine correct bytes one by one. Constant-time comparison always takes the same amount of time regardless of where the mismatch occurs, preventing this information leak. PHP's password_verify() and hash_equals() use constant-time comparison. Never use === to compare hashes, tokens, or HMAC values.$hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]); — store the resulting 60-character string in your database. To verify: if (password_verify($input, $storedHash)) { /* authenticated */ }. To check if rehashing is needed (after raising the cost factor): if (password_needs_rehash($storedHash, PASSWORD_BCRYPT, ['cost' => 12])) { $newHash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]); /* store new hash */ }. Use PASSWORD_DEFAULT instead of PASSWORD_BCRYPT if you want PHP to automatically upgrade to the strongest algorithm in future versions.$peppered = hash_hmac('sha256', $password, $PEPPER); $hash = password_hash($peppered, PASSWORD_BCRYPT);. OWASP considers peppers a reasonable additional control for high-security applications.$2a$ is the original bcrypt format with a bug in some implementations regarding 8-bit characters. $2b$ is the corrected format (fixed in OpenBSD). $2y$ is PHP-specific and equivalent to $2b$ — it was introduced before the official fix to signal the corrected behavior. For new hashes PHP uses $2y$. All three verify correctly against each other in modern implementations. If you see $2a$ hashes in an older system, they are still valid and password_verify() handles them correctly.About This Bcrypt Generator
This free bcrypt generator hashes a password using the bcrypt algorithm with a configurable cost factor (work factor). Enter a password and select a cost to generate a hash suitable for storing in a database.
Bcrypt is a password-hashing function designed for security: it is deliberately slow (controlled by the cost factor), includes a random salt in every hash, and produces a different output each time even for the same input — making it resistant to brute-force and rainbow-table attacks.
When to use this tool
- Generating test bcrypt hashes during development
- Verifying that your application stores passwords correctly
- Understanding how cost factor affects computation time
- Creating hashes for seeding a user database
Standards & References
How Bcrypt Hashing Works
Bcrypt is a password-hashing function based on the Blowfish cipher, designed to be computationally expensive by design.
Generate Random Salt
PHP's password_hash() automatically generates a 128-bit (22 Base64-character) cryptographically random salt for every call. You never provide a salt manually — this prevents salt reuse vulnerabilities.
Expand Key Over 2^cost Rounds
The password and salt are fed into the EksBlowfishSetup key schedule, which is repeated 2cost times. At cost 12 that's 4,096 expensive key expansions — far slower than SHA-256 for an attacker.
Embed Metadata in Hash
The 60-character output encodes everything needed to verify: $2y$ (algorithm), 12$ (cost), 22-char salt, and 31-char digest. The salt is embedded, so verification needs only the hash string — never separate storage.
password_verify() — never compare bcrypt hashes with === or strcmp().Common Use Cases
User Password Storage
The primary use of bcrypt. Hash the password before inserting into the database — never store plaintext. On login, call password_verify($input, $storedHash). Even if the database is breached, the hashes resist cracking.
Migrating Weak Password Hashes
If your app uses MD5 or SHA-1 passwords, migrate to bcrypt on each successful login: verify the old hash, then immediately re-hash with bcrypt and store the new value. Use this tool to test the migration.
Cost Factor Tuning
Use this tool to benchmark different cost factors on your production hardware. Aim for 250ms–1s per hash. Move the cost slider and observe generation time to find the right balance between security and UX.
Verifying Stored Hashes
Use the Verify tab to confirm a password matches an existing bcrypt hash. Useful when debugging authentication issues or testing that a hash stored in the database was generated from the expected password.
API Key & Token Hashing
API keys can be stored as bcrypt hashes rather than plaintext. The user sees the key once at creation; the server stores only the hash and verifies on each request — minimizing exposure if the database is breached.
Security Auditing
Paste a hash from a database dump to verify its format ($2y$ vs older $2a$) and cost factor. A cost below 10 is considered underpowered by today's standards and should be re-hashed on next user login.
Related Developer Tools
Related Articles
View all articles
Bcrypt's 72-Byte Limit: Why Two Different Passwords Can Hash to the Same Value
Bcrypt silently truncates input at 72 bytes — meaning two passwords sharing the same first 72 bytes but differing afterward produce the identical hash. Here's why 72 specifically, how multi-byte Unicode characters (emoji especially) reach this limit far sooner than "72 characters" suggests, why pre-hashing with SHA-256 is a common mitigation, and why this isn't actually a meaningful security concern for typical passwords.
Credential Breaches and Stuffing Attacks: What Leaked Password Databases Reveal and How HIBP Works
Have I Been Pwned has indexed 12+ billion breached accounts. Here's what a leaked credential database actually looks like, how attackers use credential stuffing at scale, the k-anonymity trick that lets HIBP check passwords without seeing them, and why bcrypt salting defeats rainbow tables.
Why bcrypt: The History of Password Hashing, Cost Factors, and When Argon2 Is Better
SHA-1 and MD5 are fast by design — which is why GPUs crack them in hours after a breach. bcrypt's deliberate slowness and automatic salting are its defence. Here's how bcrypt works, the 72-byte limit, choosing a cost factor, and when Argon2 is the better choice.
Bcrypt Generator — Hash & Verify Passwords the Right Way
Learn how bcrypt works, why slowness is the feature, what the cost factor means, how to use bcrypt for user authentication, and why MD5 and SHA-256 should never be used for passwords — with a free bcrypt generator.
Bcrypt Generator — How to Hash & Verify Passwords Correctly
Learn what bcrypt is, how the cost factor and salt work, how bcrypt hashes are structured, and how to use a free bcrypt generator to test and verify password hashes in your development workflow.