Course contentsShow
← Security
Lesson 688 of 3,05215. Web Security - Authentication and SessionsFree lesson

bcrypt: Work Factor and Adaptive Hashing

Explore bcrypt's configurable cost parameter that makes password cracking exponentially harder.

bcrypt: Work Factor and Adaptive Hashing

What you'll learn: How bcrypt's configurable cost parameter makes password cracking exponentially harder over time.

The Problem with Fixed-Speed Hashing

As you learned, fast hashes like MD5 and SHA-256 are unsuitable for passwords because attackers can compute billions of hashes per second on modern hardware. Even with salts (which prevent rainbow tables), an attacker can still brute-force billions of password guesses quickly.

What is bcrypt's Work Factor?

bcrypt introduces a cost parameter (also called work factor) that controls how computationally expensive the hashing process is. This number determines how many iterations of internal processing bcrypt performs—and the computation time doubles with each increment.

Think of it like turning up the difficulty dial on a lock. A cost of 10 might take 0.1 seconds to hash one password. A cost of 11 takes 0.2 seconds. Cost 12 takes 0.4 seconds, and so on. For legitimate users logging in once, this delay is barely noticeable. For attackers trying billions of combinations, it's devastating.

Adaptive Hashing: Future-Proofing Security

This is where bcrypt shines. As computers get faster over the years, you can simply increase the work factor without changing your entire system. This "adaptive" approach means your password hashing stays secure against improving hardware—you can incrementally increase the cost to maintain the same level of computational defense.

The work factor is stored in the hash itself, so different passwords can have different costs, making gradual upgrades seamless during user logins.

Key Takeaway: bcrypt's configurable work factor makes each hash intentionally slow and expensive to compute, turning password cracking from seconds into years, while allowing you to increase security as computing power advances.