Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Bcrypt Hash Generator & Password Checker

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.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
Generate a hash
Check a password

Runs in your browser. Passwords never leave this page. Tip: aim for about 250 ms per hash on your server

How to use the bcrypt tool#

  1. To create a hash, type a password, set the Cost (10–12 is typical) and the Prefix ($2y$ for PHP and Laravel), then press Generate hash.
  2. The colours show the four parts of the hash: version, cost, salt and the hash itself, with an explanation underneath.
  3. To test a login, type a password and paste a stored hash under Check a password, then press Check password.
  4. Watch the timing: each +1 in cost doubles the work. Aim for about 250 ms per hash on your server.

Examples#

Check a password against a stored hash

Input
dev247
Output
✓ Match

This hash was created with PHP's password_hash(), exactly as Laravel's Hash::make() does.

Generate a hash

Input
correct horse battery staple
Output
$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.

What is bcrypt?#

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).

Anatomy of a bcrypt hash#

plaintext
$2y$10$N9qo8uLOickgx2ZMRZoMye IjZAgcfl7p92ldGxad68LJZdL17lhWy │   │  └──── salt (22) ────┘ └────── hash (31) ──────┘ │   └ cost: 2^10 = 1,024 rounds └ version
PartLengthMeaning
Version4$2a$, $2b$ or $2y$
Cost2 digitslog₂ of the number of rounds (04–31)
Salt22 characters128 random bits, in bcrypt's own Base64 alphabet
Hash31 characters184 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.

$2a$, $2b$ and $2y$: what is the difference?#

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.

Choosing the cost#

CostRoundsTypical time on a server
101,024~50–100 ms
124,096~200–300 ms (Laravel's default)
1416,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.

The 72-byte limit#

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.

bcrypt vs Argon2 vs scrypt#

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.

bcrypt in code#

PHP / Laravel#

php
$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);

Node.js#

javascript
import bcrypt from 'bcryptjs'; const hash = await bcrypt.hash(password, 12);const ok = await bcrypt.compare(password, hash);

Python#

python
import bcrypt hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))bcrypt.checkpw(password.encode(), hashed)

Common errors and fixes#

  • 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).

Frequently asked questions#

Can a bcrypt hash be decrypted?

No. bcrypt is one-way. The only way to find a password is to guess it, and bcrypt's slowness makes each guess expensive.

Why is the hash different every time?

A new random salt is generated for each hash. The salt is stored inside the hash, so every version still verifies the same password.

What cost does Laravel use?

Laravel uses bcrypt with a cost of 12 by default (the BCRYPT_ROUNDS setting) and produces $2y$ hashes.

How long is a bcrypt hash?

Always 60 characters: 4 for the version, 2 for the cost, a separator, 22 for the salt and 31 for the hash.

Is it safe to type a real password here?

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.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.