How Password Hashing Works: bcrypt, scrypt, and Argon2

Storing passwords in plain text is a catastrophic security failure. Password hashing protects users even if your database is breached.

Why not just use SHA-256? SHA-256 is designed to be fast. On modern hardware, an attacker can compute billions of SHA-256 hashes per second to brute-force passwords. Password hashing algorithms are deliberately slow and resource-intensive to make brute-force attacks impractical.

bcrypt (1999) was the first widely-adopted password hashing algorithm. It includes a built-in salt (random data added to each password before hashing, preventing identical passwords from producing identical hashes) and a cost factor that can be increased as hardware gets faster. Still secure and widely used.

scrypt (2009) adds memory-hardness to bcrypt's CPU-hardness. It requires significant RAM to compute, making it resistant to attacks using specialized hardware (ASICs, GPUs). If bcrypt is like a heavy weight to lift, scrypt is like needing a large space to exercise — it requires both effort and resources.

Argon2 (2015) won the Password Hashing Competition and is the current state of the art. It has three variants: Argon2d (resists GPU attacks), Argon2i (resists side-channel attacks), and Argon2id (hybrid, recommended). Argon2 is memory-hard and configurable for both time and memory cost.

What to use today: Argon2id is the recommended choice for new applications. bcrypt is acceptable if Argon2 is unavailable. Never use MD5, SHA-1, or raw SHA-256/SHA-512 for password storage.

Use Tooler's Hash Generator for general-purpose file and text hashing, but use a dedicated authentication library for password storage.