Course contentsShow
← Software Engineering
Lesson 1003 of 1,93331. Authentication and AuthorizationFree lesson

Work Factors and Adaptive Hashing

Configuring hash iteration counts to balance security and performance as hardware capabilities evolve.

Work Factors and Adaptive Hashing

What you'll learn: How to configure hash iteration counts to keep password security strong as computers get faster over time.

The Core Problem

In Lesson 1002, you learned about bcrypt, scrypt, and Argon2—algorithms designed to be slow on purpose. But here's the challenge: what's "slow enough" today becomes dangerously fast tomorrow as hardware improves. A hash that took 100ms to compute in 2015 might take only 10ms in 2025.

What is a Work Factor?

The work factor (also called "cost factor" or "iteration count") is a configurable parameter that controls how many computational rounds the hashing algorithm performs. Higher work factor = more iterations = slower hashing = harder for attackers to crack.

Think of it like adjusting the difficulty on a treadmill. As you get fitter (hardware gets faster), you increase the incline (work factor) to maintain the same challenge level.

Adaptive Hashing in Practice

bcrypt uses a cost parameter (typically 10-12):

  • Cost of 10 = 2^10 = 1,024 iterations
  • Cost of 12 = 2^12 = 4,096 iterations
  • Each increment doubles the work

Argon2 allows tuning memory, parallelism, and iterations independently, making it even more adaptable to evolving threats.

Balancing Security and Performance

You want password hashing to take 200-500ms per attempt:

  • Too fast (<50ms): Attackers can try millions of passwords quickly
  • Too slow (>1s): Your login system becomes unresponsive under normal load

Review and increase your work factor every 1-2 years as hardware capabilities grow. When users log in successfully, you can transparently rehash their password with the new, higher work factor.

Key Takeaway: Adaptive hashing with configurable work factors lets you "future-proof" password security by incrementally increasing computational cost as hardware evolves, maintaining effective defense against brute-force attacks.