What is inside a bcrypt hash
A bcrypt hash is always 60 characters and carries everything needed to check it later:
$2y$10$NcruEd5eCuEXoXwoswj9zO5HpfKrkHyVlvXvMt85l4jYSbg8MfYwi
- The opening $2y$ is the version. This tool produces $2a$, and it can verify $2a$, $2b$ and $2y$ hashes.
- The next two digits are the cost, 10 in this example.
- The next 22 characters are the random salt.
- The last 31 characters are the hash itself.
Because the salt travels inside the hash, a database needs only this one column, and two users with the same password still get different values.
Picking the cost factor
The work doubles with each step: cost 10 runs 1,024 rounds, 12 runs 4,096 and 14 runs 16,384. OWASP suggests 10 as the minimum. Time it on your production server and choose the highest value that keeps a login to a few hundred milliseconds.
This page runs bcrypt in JavaScript, which is slower than a server library, so high costs can freeze the tab for a few seconds. That delay says little about how fast your own server will be.
The 72-byte limit
Bcrypt reads only the first 72 bytes of a password and silently ignores the rest. Bytes are not the same as characters: an emoji takes 4 bytes in UTF-8 and a Bangla letter takes 3, so the limit can arrive sooner than it appears. Very long passphrases that differ only after that point will match the same hash.
Using it in your own code
This tool suits test data, seeding a first admin account and checking that a stored hash is what you expect. In an application, hash on the server, never in the visitor’s browser.
// PHP
$hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]);
$matches = password_verify($password, $hash);
// Node.js with the bcrypt package
const hash = await bcrypt.hash(password, 12);
const matches = await bcrypt.compare(password, hash);
For a brand-new system, OWASP’s first choice is now Argon2id. Bcrypt remains a sound option where Argon2id is not available.