How should you store passwords, and why not SHA-256 or encryption?
Short answer
Use a slow password hash with a salt and cost parameters: Argon2id by default, bcrypt is still fine, PBKDF2 when you need FIPS. SHA-256/MD5 are too fast (GPUs try billions per second), and encryption is the wrong model because you never need to read the password back.
3 points to say:
- A slow, memory-hard algorithm: Argon2id (OWASP suggests m=19 MiB, t=2, p=1); bcrypt cost 10–12, 72-byte input limit.
- A unique salt per password (defeats rainbow tables); keep the pepper outside the DB.
DelegatingPasswordEncoderstores an{id}prefix so you can migrate algorithms gradually as users log in again.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.