Bcrypt Explained: How Passwords Should Be Stored

Bcrypt Explained: How Passwords Should Be Stored

Every data breach story contains the same line: “passwords were stored in plain text.” It’s the most avoidable mistake in software — and bcrypt is the standard fix.

Why plain hashing fails

Hashing a password (SHA-256, MD5) sounds safe — the stored value isn’t readable. The problem: hashing is fast. A modern GPU tries billions of hashes per second, and attackers precompute tables of common-password hashes. Fast hashing + predictable passwords = cracked in minutes.

Bcrypt’s answer is deliberate slowness: it runs the hashing function thousands of times in a loop (the “cost factor”), making each attempt ~100 ms instead of microseconds. A billion guesses becomes years of compute.

The features that matter

  • Salting, built in: bcrypt adds a random value to each hash automatically, so two users with the same password get different hashes — precomputed tables become useless.
  • Tunable cost: the work factor scales with hardware. As computers get faster, you raise it.
  • Format self-describing: $2a$10$... records the algorithm and cost inside the hash itself, so verification always uses the right settings.

Using it

  1. Enter a password in the bcrypt generator — it produces the hash locally, in your browser. Nothing is transmitted.
  2. Store the hash in your database. On login, bcrypt’s verify function compares the entered password against the stored hash.
  3. Never “decrypt” — bcrypt is one-way by design. Password reset, not password recovery.

The modern caveat

Bcrypt remains a solid default, though newer algorithms (Argon2) are preferred for new systems with high security needs. For most applications, bcrypt’s two-decade track record is exactly the kind of boring reliability you want guarding credentials.

The rule that never changes: your system should not be able to read passwords — only to verify them.