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

Password Hashing Algorithms: bcrypt, scrypt, and Argon2

Comparing modern password hashing algorithms designed to be computationally expensive and resist brute-force attacks.

Password Hashing Algorithms: bcrypt, scrypt, and Argon2

What you'll learn: How modern password hashing algorithms defend against brute-force attacks by being intentionally slow and resource-intensive.

The Need for Expensive Hashing

You already know that salts prevent rainbow table attacks. But even with salts, attackers with powerful hardware can still try billions of password guesses per second using algorithms like SHA-256. Modern password hashing algorithms solve this by being deliberately slow and resource-hungry, making brute-force attacks impractical.

The Three Champions

bcrypt (1999) was the first widely-adopted algorithm designed specifically for password hashing. It includes a "cost factor" parameter that controls how many computational rounds it performs. As computers get faster, you can increase the cost factor to maintain security. Think of it like adding speed bumps on a road—the more you add, the slower attackers must go.

scrypt (2009) goes further by requiring significant memory in addition to CPU time. This "memory-hard" approach makes it extremely expensive to build specialized hardware (like ASICs) for cracking passwords. It's like requiring attackers to not only solve a puzzle, but solve it while juggling—parallel hardware can't help much.

Argon2 (2015) is the newest, winning the Password Hashing Competition. It comes in variants (Argon2i, Argon2d, Argon2id) offering different trade-offs. Argon2id is generally recommended—it combines resistance to both timing attacks and GPU-based cracking, while allowing you to tune memory usage, CPU time, and parallelism independently.

Choosing Your Algorithm

All three are excellent choices. Argon2 is the current best practice. bcrypt remains solid and battle-tested. scrypt offers strong memory-hardness. The key is tuning parameters so hashing takes 250-500ms on your server—long enough to frustrate attackers, short enough not to annoy users.

Key Takeaway: Modern password hashing algorithms like bcrypt, scrypt, and Argon2 intentionally consume significant CPU and memory resources to make brute-force attacks economically infeasible, with Argon2 being the current gold standard.