SecLab
Authentication & SessionwalkthroughDifficulty 2/526 min

Storing passwords, and why you should not store them

Objective: After this lesson you can choose a password hashing algorithm and its parameters, and know why the better question is "do we need passwords at all".

V6API2:2023A07:2025jwt
Step 1 of 5 · read6 min

Three kinds of hash, two of them wrong

Password hashing is one of the few areas of application security with a settled answer. No architectural trade-off, no dependence on context: there are three correct choices and everything else is wrong.

What makes people choose wrongly is that the word "hash" carries two entirely different meanings:

KindExamplesDesigned to beUse for passwords?
General cryptographic hashSHA-256, SHA-3, BLAKE3FastNo
MACHMAC-SHA256Authenticate integrityNo
Password hashArgon2id, scrypt, bcryptSlow and memory-hungryYes

SHA-256 is not "weak" — it is an excellent hash for what it was designed for. The problem is that it is fast, and fast is the worst possible property for a password: a modern GPU tries billions of SHA-256 per second, so an 8-character password hashed with SHA-256 falls in hours, salt or no salt.

Salt solves a different problem and is routinely thought to solve this one. Salt defeats rainbow tables and stops two users with the same password sharing a hash — it does not make cracking one specific password slower. That is the work factor's job.

The parameters to use, per the OWASP Password Storage Cheat Sheet:

AlgorithmParameters
Argon2id (preferred)m=19 MiB, t=2, p=1 — or m=47 MiB, t=1, p=1
scryptN=2^17, r=8, p=1
bcryptcost ≥ 10, and mind the 72-byte limit

The bcrypt trap is worth knowing: it silently discards every byte past the 72nd. With a long passphrase, or a Vietnamese password with diacritics (2–3 UTF-8 bytes per character), the tail is dropped with no warning.

But the better question than all three rows above is: do you need passwords? Store no password and there is nothing to leak, nothing to hash wrongly, and nobody reusing their password from a site that was already breached. Passkeys (WebAuthn) and OIDC with a provider both remove this problem rather than solving it.

View path

Comments

Join the discussion
Sign up to comment

Commenting needs an account with at least one completed lesson. That condition is what keeps this thread worth reading: every point belongs to someone who can be asked back, and reputation accrues over time.

Sign upSign in

You can still read every comment below without an account. Signing in brings you back to this exact spot, not to the top of the page.

Loading comments…