Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

Bcrypt Generator

Ready
Runs in your browser. Nothing you paste is uploaded unless you share it.

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

  1. Type a password; it is hashed as you type, in the background.
  2. Pick the algorithm, then the cost and prefix (bcrypt) or the settings your library expects, and copy the hash.
  3. 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

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

Input
Password: correct horse battery staple
Hash: $2b$10$VimNI3JvLvW4gJvSNqmQd.wk8G/RkRbKfOe0ibByf1Q1TUcaLSQfm
Result
Match

What a bcrypt hash holds

A bcrypt hash is 60 characters and carries everything needed to check a password later: the version, the cost and the salt sit in front of the result, so you store this one string and nothing else.

PartIn $2b$10$VimNI3JvLvW4gJvSNqmQd.wk8G/RkRbKfOe0ibByf1Q1TUcaLSQfmWhat it is
Prefix$2b$The version mark: $2b$ today, $2a$ in older libraries, $2y$ from PHP
Cost10The work factor: 2^10 = 1,024 rounds of the key setup
SaltVimNI3JvLvW4gJvSNqmQd.22 characters (128 random bits), new for every hash
Hashwk8G/RkRbKfOe0ibByf1Q1TUcaLSQfm31 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

Each step up in cost doubles the time a hash takes, for you and for anyone trying to guess the password. OWASP’s guidance is a cost of at least 10; pick the highest your login can afford, often a hash of about a quarter of a second on your server.

The list shows how long each cost takes in this browser, estimated from the last hash timed here, and stops at costs that would run longer than half a minute. Your server may be faster or slower than this device, so time it there too.

CostRoundsTypical use
4-916-512Tests only: too fast to slow down guessing
101,024OWASP’s minimum; the default of bcryptjs
124,096The default of PHP 8.4’s password_hash; a common choice for new systems
13-148,192-16,384Where a slower login is acceptable

The 72-byte limit and the $2a$, $2b$, $2y$ prefixes

bcrypt reads at most 72 bytes of a password; characters after them do not change the hash. Letters outside English take 2 to 4 bytes each in UTF-8, so the limit can come sooner than 72 characters. The page counts the bytes and says so when a password is longer.

$2a$, $2b$ and $2y$ run the same algorithm for every password of 72 bytes or fewer. $2b$ is OpenBSD’s 2014 mark, $2y$ is what PHP’s password_hash writes, and $2a$ is the older form; pick the one your library expects. Verify reads all three.

Argon2id, scrypt and PBKDF2

Pick another algorithm to get its hash in the form libraries store: $argon2id$v=19$m=19456,t=2,p=1$salt$hash (argon2-cffi, libsodium, PHP’s password_hash with PASSWORD_ARGON2ID), $scrypt$ln=17,r=8,p=1$salt$hash (passlib) and pbkdf2_sha256$600000$salt$hash (Django). The settings listed are OWASP’s, so the hash takes the time those settings cost on this device.

Verify reads all of them, plus Argon2i and Argon2d, and checks the password with the settings written in the hash. A hash asking for more than 256 MiB of memory or 20 million PBKDF2 rounds is named and not run, so a pasted hash can’t stall the tab.

Hashing and checking in code

Every language has a bcrypt library that makes the salt for you and reads the cost back from the hash, so a check needs only the password and the stored hash. Compare with the library’s check function, never by hashing again and comparing strings: the new salt makes a different hash.

Some libraries now refuse a password over 72 bytes instead of cutting it short: Go’s golang.org/x/crypto/bcrypt returns an error, and so does Python’s bcrypt from version 5.0. PHP 8.4 raised the default cost of password_hash from 10 to 12.

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

Related tools