Password hashing ensures that even if a database is leaked, attackers cannot directly read user passwords. A hash is a one-way function — it cannot be reversed, but it can be compared.
Core Concepts
Salt: a unique random value per password to prevent rainbow table attacks.
Pepper: a global secret stored separately from the database.
Key stretching: multiple iterations to slow down brute-force attempts.
Recommended Algorithms
Argon2: modern and memory-hard, ideal default choice.
bcrypt: well-tested, battle-proven algorithm for most systems.
PBKDF2: older but reliable if configured with strong parameters.