Check a password against a stored hash
dev247
✓ Match
This hash was created with PHP's password_hash(), exactly as Laravel's Hash::make() does.
Hash a password with bcrypt at any cost, check a password against an existing hash, and see what every part of a bcrypt hash means. Works with PHP and Laravel ($2y$) hashes.
$2y$ for PHP and Laravel), then press Generate hash.dev247
✓ Match
This hash was created with PHP's password_hash(), exactly as Laravel's Hash::make() does.
correct horse battery staple
$2y$10$… (60 characters, different every time)
A new random salt is used for each hash, so hashing the same password twice gives different results. Both verify.
bcrypt is a password hashing function designed to be slow on purpose, so that attackers who steal a database cannot test billions of password guesses per second. It was created by Niels Provos and David Mazières in 1999, based on the Blowfish cipher, and is the default password hash in PHP, Laravel, Ruby on Rails and many other frameworks.
Unlike MD5 or SHA-256, bcrypt adds a random salt to every hash (so identical passwords get different hashes) and has an adjustable cost (so it can be made slower as computers get faster).
$2y$10$N9qo8uLOickgx2ZMRZoMye IjZAgcfl7p92ldGxad68LJZdL17lhWy │ │ └──── salt (22) ────┘ └────── hash (31) ──────┘ │ └ cost: 2^10 = 1,024 rounds └ version| Part | Length | Meaning |
|---|---|---|
| Version | 4 | $2a$, $2b$ or $2y$ |
| Cost | 2 digits | log₂ of the number of rounds (04–31) |
| Salt | 22 characters | 128 random bits, in bcrypt's own Base64 alphabet |
| Hash | 31 characters | 184 bits of the result |
The whole hash is always 60 characters. The salt is stored inside it, which is why checking a password only needs the password and the hash.
They all use the same algorithm and produce the same result for normal passwords. $2a$ was the original; a bug in some implementations led to $2y$ (PHP's fixed version, 2011) and $2b$ (OpenBSD's fixed version, 2014). PHP and Laravel create $2y$, while most other languages create $2b$. Most libraries accept all three, and changing $2y$ to $2b$ is safe when a library refuses one.
| Cost | Rounds | Typical time on a server |
|---|---|---|
| 10 | 1,024 | ~50–100 ms |
| 12 | 4,096 | ~200–300 ms (Laravel's default) |
| 14 | 16,384 | ~1 s |
Pick the highest cost that keeps a login under about a quarter of a second on your own server. Measure it there: the time shown by this tool is your browser's, which is usually slower.
bcrypt only uses the first 72 bytes of a password; the rest is silently ignored. That is plenty for normal passwords, but long passphrases with emoji or non-Latin characters (several bytes each) can reach it. The tool warns you when a password is longer than 72 bytes.
Argon2id, the winner of the 2015 Password Hashing Competition, is the modern recommendation because it is also memory-hard, which makes GPU cracking more expensive. bcrypt remains a solid, widely supported choice. Never use plain MD5, SHA-1 or SHA-256 for passwords.
$hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]);password_verify($password, $hash); // true / false // Laravel$hash = Hash::make($password); // $2y$12$…Hash::check($password, $hash);import bcrypt from 'bcryptjs'; const hash = await bcrypt.hash(password, 12);const ok = await bcrypt.compare(password, hash);import bcrypt hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))bcrypt.checkpw(password.encode(), hashed)password_verify() always returns false
The stored hash is probably cut off: bcrypt hashes are 60 characters, and a VARCHAR(50) column truncates them. Use VARCHAR(255). Also check the password was not trimmed or changed before hashing.
A hash from PHP ($2y$) is rejected in another language
Some libraries only accept $2a$ or $2b$. Replace the $2y$ prefix with $2b$: the algorithm is the same, so the hash still verifies.
Login became very slow
The cost is too high for your server. Lower it by one or two; each step halves the time. Existing hashes keep working at their own cost.
Two different long passwords both work
They share the same first 72 bytes, which is all bcrypt uses. Limit password length or pre-hash long passwords carefully (for example with HMAC-SHA256, then Base64).
No. bcrypt is one-way. The only way to find a password is to guess it, and bcrypt's slowness makes each guess expensive.
A new random salt is generated for each hash. The salt is stored inside the hash, so every version still verifies the same password.
Laravel uses bcrypt with a cost of 12 by default (the BCRYPT_ROUNDS setting) and produces $2y$ hashes.
Always 60 characters: 4 for the version, 2 for the cost, a separator, 22 for the salt and 31 for the hash.
Hashing and checking run entirely in your browser and nothing is sent anywhere. Still, as good practice, avoid entering passwords you use for important accounts on any website.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.