Somewhere in your user database there is a column full of strings that look like line noise: sixty characters, a few dollar signs, no spaces, no readable words. They are not corrupted data, and they are not encrypted passwords waiting for a key. Each one is a bcrypt hash, and underneath the noise it is one of the most carefully self-describing formats in everyday software.

A bcrypt hash carries everything needed to check a password inside the string itself: which version of the algorithm made it, how much work went into it, the random salt that was mixed in, and only then the hash. This guide reads a real one part by part, using the free Bcrypt Hash Generator on Ovatly, so the next time you meet one in a database or a log, you know exactly what you are looking at.

Contents

  • Quick answer
  • The four parts, in order
  • Why the salt and cost live inside the string
  • The one surprise: 72 bytes and no more
  • How to generate a hash and read it, step by step
  • Worked example: reading a real hash piece by piece
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

A bcrypt hash is a single string of 60 characters with four parts in fixed positions. It opens with the version marker $2b$, followed by a two-digit cost factor such as 10, then a 22-character salt, then the 31-character hash itself. Nothing else needs to be stored: the salt and cost ride inside the string, so verification reads them back out and repeats the same work. Generate one with the Bcrypt Hash Generator, then paste it into the verify section with the original password to get a match or a no-match. One surprise hides in the format: bcrypt only uses the first 72 bytes of any password, and everything past that is ignored.

The four parts, in order

Read a bcrypt hash left to right and it parses like a tiny form with four fields.

The version marker comes first: $2b$. It names the revision of the bcrypt algorithm that produced the string, so future software can tell older hashes from newer ones and handle each correctly.

Next is the cost factor, two digits such as 10. This records how much work the hashing deliberately did. In the Ovatly tool the cost can be set from 4 to 12, and 10 is the classic default. Cost 12 takes four times as long as cost 10, a detail the companion guide in this series pulls apart.

The salt follows: 22 characters of randomness, generated fresh on every run. Because the salt changes each time, the same password never hashes the same way twice, and precomputed tables of common-password hashes become useless: every entry would need a different salt.

Last comes the hash itself, the remaining 31 characters. This is the actual output of running the password and salt through bcrypt at the stated cost. Everything before it is the recipe; these 31 characters are the result.

Why the salt and cost live inside the string

Verifying a password against bcrypt means redoing the work: take the password the user just typed, run it through bcrypt with the same salt and the same cost, and see whether the result matches. That is only possible if the salt and cost are still available at login time.

bcrypt's answer is to store them in the output. The database needs exactly one column, and nothing can get separated from anything else: no salt column to leave blank, no settings file that says cost 10 while the hashes were made at cost 12. Verification extracts the salt and cost from the stored string automatically, applies them to the candidate password, and compares. If the stored string is damaged or incomplete, verification does not try to be clever; a malformed hash is treated as a simple no-match.

The one surprise: 72 bytes and no more

The format hides one behaviour that catches people out. bcrypt truncates its input at 72 bytes. A 60-character password is used in full, but a 100-character passphrase is silently cut down to its first 72 bytes, and the rest might as well not exist. Two passwords that agree on their first 72 bytes and differ afterwards produce the same hash.

For ordinary passwords this never matters. For very long generated secrets and passphrases, the honest advice is that length past 72 bytes adds nothing.

How to generate a hash and read it, step by step

  1. Open the Bcrypt Hash Generator and type or paste the password into the input field.
  2. Set the cost factor. Leave it at 10 unless you have a reason to change it; the tool warns at 11 and 12 because higher costs can freeze a browser tab while it works.
  3. Click Generate and copy the 60-character result.
  4. To check a password later, scroll to the verify section, paste the password and the stored hash, and read the verdict: match or no-match.

Worked example: reading a real hash piece by piece

Hashing the password correct horse battery staple at cost 10 in the tool produced this string in one run:

$2b$10$jT61zASMuZO.BYMYrC8tVOrG4f70YI6WdfYJA2RvF4xQe9jYzcUa.

Now split it at the joints. $2b$ is the version marker. 10 is the cost factor. The next 22 characters, jT61zASMuZO.BYMYrC8tVO, are the salt chosen for that run. The remaining 31 characters, rG4f70YI6WdfYJA2RvF4xQe9jYzcUa., are the hash itself. Seven characters of header, 22 of salt, 31 of hash: 60 in total, every time.

Run the same password again and the salt and hash portions will look completely different, because a fresh salt is drawn each time. The header will still read $2b$10$ as long as the cost stays at 10, and the verify section will still confirm the password against either string.

Limitations and honest tradeoffs

Because the salt is fresh on every run, two hashes of the same password cannot be compared as strings. Judging equality means running the verify step, never eyeballing two outputs side by side.

The in-browser tool caps cost at 12 and warns at the top end, because a browser tab is a fragile place to do deliberately slow work. Real applications tune cost against their own server, commonly landing between 10 and 13, and that range is wider than what a teaching tool should attempt. bcrypt is also no longer the newest option: Argon2id is the modern alternative, adding memory hardness that resists GPU-based guessing. What never becomes acceptable is storing passwords with a fast hash such as SHA-256, which is built for speed and therefore cheap to guess against.

Common mistakes

  • Comparing two hash strings to check a password. Fresh salt means they will never match as text. Always use the verify step.
  • Splitting the string into separate fields. Storing the salt in one column and the hash in another invites losing or mismatching a piece. Keep all 60 characters together.
  • Truncating the stored string. A database column that clips the value produces a malformed hash, and every login for that user becomes a no-match.
  • Assuming a longer password always helps. Past 72 bytes, bcrypt ignores the rest, so extra length adds nothing.
  • Treating the output as a secret to hide from yourself. The string is designed to be stored openly in a database; the password is what stays secret.

FAQs

How long is a bcrypt hash? Always 60 characters. The first 7 characters are the version marker and cost ($2b$10$), the next 22 are the salt, and the remaining 31 are the hash itself.

Why does the same password produce a different hash every time? Because a fresh random salt is generated on every run and stored inside the result. Two runs salt the same password differently, so the outputs differ, and precomputed rainbow tables cannot match either one.

Where are the salt and cost stored? Inside the hash string itself. The cost sits right after the version marker and the salt follows it, so a database only needs one column for the whole string and verification can extract both values automatically.

What happens if I paste a damaged or incomplete hash into the verify box? Verification treats a malformed hash as a simple no-match. It does not error or guess; the password simply fails to verify, the same as if you had typed the wrong password.

Does bcrypt use all of a very long password? No. bcrypt truncates its input at 72 bytes, so characters beyond that point are ignored. Two passwords that share the same first 72 bytes produce the same result.

Conclusion

A bcrypt hash stops looking like noise once you know the layout: version, cost, salt, hash, in that order, in 60 characters. The design earns its keep every login, because the string carries everything verification needs and nothing it does not. The Bcrypt Hash Generator lets you generate and verify examples until the parts are familiar. Choosing the cost number wisely is the other half of using bcrypt well, and our guide to bcrypt cost mistakes covers exactly that. For more guides in this series, see our Security and Privacy Utilities guides.

References