Hash a password with bcrypt, Argon2id, scrypt or PBKDF2 at OWASP settings, or check a password against a hash of any of them
Type a password to get its bcrypt hash at the cost you pick, or its Argon2id, scrypt or PBKDF2 hash, or switch to Verify to check a password against a hash.
How to use it
Type a password; it is hashed as you type, in the background. Pick the algorithm, then the cost and prefix (bcrypt) or the settings your library expects, and copy the hash. To check one, choose Verify and paste the hash under the password: $2b$…, $argon2id$…, $scrypt$… or Django’s pbkdf2_sha256$… are read.
Examples
Hash at cost 10
correct horse battery staple
$2b$10$VimNI3JvLvW4gJvSNqmQd.wk8G/RkRbKfOe0ibByf1Q1TUcaLSQfm
The salt is random, so your hash of the same password differs; both check as a match.
Verify a password
Password: correct horse battery staple Hash: $2b$10$VimNI3JvLvW4gJvSNqmQd.wk8G/RkRbKfOe0ibByf1Q1TUcaLSQfm
Match
What a bcrypt hash holds
| Part | In $2b$10$VimNI3JvLvW4gJvSNqmQd.wk8G/RkRbKfOe0ibByf1Q1TUcaLSQfm | What it is |
|---|---|---|
Prefix | $2b$ | The version mark: $2b$ today, $2a$ in older libraries, $2y$ from PHP |
Cost | 10 | The work factor: 2^10 = 1,024 rounds of the key setup |
Salt | VimNI3JvLvW4gJvSNqmQd. | 22 characters (128 random bits), new for every hash |
Hash | wk8G/RkRbKfOe0ibByf1Q1TUcaLSQfm | 31 characters (184 bits) of the result |
Sources: Provos and Mazières, A Future-Adaptable Password Scheme (USENIX 1999), OWASP Password Storage Cheat Sheet
Which cost to pick
| Cost | Rounds | Typical use |
|---|---|---|
4-9 | 16-512 | Tests only: too fast to slow down guessing |
10 | 1,024 | OWASP’s minimum; the default of bcryptjs |
12 | 4,096 | The default of PHP 8.4’s password_hash; a common choice for new systems |
13-14 | 8,192-16,384 | Where a slower login is acceptable |
The 72-byte limit and the $2a$, $2b$, $2y$ prefixes
Argon2id, scrypt and PBKDF2
Hashing and checking in code
// Node.js (bcrypt or bcryptjs) const hash = await bcrypt.hash(password, 12); const ok = await bcrypt.compare(password, hash); # Python (bcrypt) hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12)) ok = bcrypt.checkpw(password.encode(), hashed) // PHP $hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]); $ok = password_verify($password, $hash); // Go (golang.org/x/crypto/bcrypt) hash, err := bcrypt.GenerateFromPassword([]byte(password), 12) err = bcrypt.CompareHashAndPassword(hash, []byte(password)) // nil means a match
Questions
- What is the difference between $2a$, $2b$ and $2y$?
The prefixes mark fixes, not different algorithms. In 2011 a bug was found in crypt_blowfish, the code PHP used, with characters outside ASCII; its fixed hashes were marked $2y$ (and the old faulty ones $2x$). In 2014 OpenBSD fixed a bug with passwords over 255 bytes and marked its hashes $2b$. For any password of 72 bytes or fewer the three give the same hash, so a $2y$ hash checks in a library that writes $2b$ once the prefix is swapped, and most libraries read all three. - Why does the same password give a different hash each time?
Every hash gets a new random salt, stored inside the hash itself. Two people with the same password then get different hashes, and a check reads the salt back from the hash, so each one still matches. - Can a bcrypt hash be decrypted?
No. bcrypt is a one-way hash, not encryption: the only way back is to guess passwords and hash each guess at the same cost, which the cost is there to make slow. - Should I use bcrypt or Argon2id?
OWASP’s Password Storage Cheat Sheet puts Argon2id first (19 MiB of memory, 2 passes), then scrypt (N = 2^17, r = 8, p = 1), then bcrypt (cost 10 or more) for older systems, and PBKDF2 where FIPS-140 approval is needed (600,000 rounds of HMAC-SHA-256). Memory-hard Argon2id and scrypt make guessing on graphics cards costly; bcrypt still holds up but reads only 72 bytes of a password. - Is my password sent anywhere?
No. Everything runs in your browser, so your text stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with a share password you choose.