Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Blog/Security

Why password hashing is slow on purpose

Fast code is usually good. For passwords, it's a gift to attackers. Here's why slow hashing, salts and Argon2 keep a leaked database from hurting you.

Derpx068 Nov · 5 min read
Contents
First, what even is a hash?What do attackers actually get from a leak?Why are fast hashes a bad idea here?What does a salt fix, and what doesn't it fix?How does "slow" actually protect you?Which slow hash do I pick?How do I tune the knob?So what would I do differently?Sources
0% read · 5 min leftBack to top ↑
On this page0%
Contents
First, what even is a hash?What do attackers actually get from a leak?Why are fast hashes a bad idea here?What does a salt fix, and what doesn't it fix?How does "slow" actually protect you?Which slow hash do I pick?How do I tune the knob?So what would I do differently?Sources

Most of computer science is about making things faster. Password hashing is the exception: it is made slower on purpose.

Here is the question for this article. If an attacker steals the database, why does a slow function protect you when a fast one does not?

First, what even is a hash?

A hash works like a one-way blender. You put a password in, a scrambled string comes out, and you can't turn it back. A site stores the scrambled string, not your password, so it never has to keep the real thing.

When you log in, the site scrambles what you typed and checks whether the result matches. The same input always gives the same output. That last fact is where the trouble starts.

So what happens when someone steals that database?

What do attackers actually get from a leak?

Say a database leaks. The attacker doesn't get passwords. They get the scrambled strings.

So they play a guessing game. They take a guess, scramble it, and compare it to the leaked string. If it matches, they found the password. A hash can't be reversed, but it can be guessed at. That is the whole attack.

Click Next to follow one guess. The attacker repeats steps 2 to 4 again and again.

Leaked hash
Attacker's guess
Hash function
Compare

The attacker holds a leaked scrambled string

Step 1 of 5
A simplified picture of a guessing attack. Real attackers automate this loop.

Each guess costs one hash. So the cheaper one hash is, the more guesses the attacker gets.

Think of a combination lock

Nobody can read the code off the lock. But if the lock lets you try 1,000 codes a second, it opens quickly.

So how fast are normal hashes?

Why are fast hashes a bad idea here?

Hashes like SHA-256 were built to be quick, which is great for checking files. For passwords, that speed helps attackers. OWASP (a group that writes security guides) says fast hashes "allow attackers to perform large numbers of guesses quickly."

The Provos and Mazières bcrypt paper has a neat history lesson. In 1976, Unix crypt could hash fewer than 4 passwords per second. About 20 years later, a fast workstation could do over 200,000 per second. That's roughly 50,000 times faster.

Unix crypt, 19761976: under 4 guesses per second
→
A fast workstationAbout 20 years later: over 200,000 per second

Computers keep getting faster, so a password scheme that never changes keeps getting weaker. The paper's main point is that the cost of a secure password scheme has to grow as hardware improves.

What about salt? Does it fix this?

What does a salt fix, and what doesn't it fix?

Two users with the same password get the same scrambled string. That's bad, because cracking one cracks both. An attacker could even prepare a giant lookup table of common passwords ahead of time.

A salt fixes this. It's a random string, unique per user, mixed into the password before hashing. OWASP describes it as "a unique, randomly generated string that is added to each password."

Salt

A random extra input, different for every user. It stops lookup tables and makes identical passwords look different. It does not slow down guessing.

The last line matters. The bcrypt paper says it too: a salt doesn't stop brute-force guessing. It only removes the shortcuts. A salt is not a substitute for slowness.

So we also need something that makes every single guess expensive.

How does "slow" actually protect you?

If one hash takes a tiny moment, a login still feels instant to you. But an attacker needs millions of guesses, so that tiny moment adds up to a huge cost.

OWASP's advice is that the hash should take less than about one second. You wait once. The attacker waits millions of times.

1Slow hash
2Each guess costs time
3Millions of guesses cost a lot
4Attack gets too expensive
The delay is small for you, because it happens once.

So which slow hash should you pick?

Which slow hash do I pick?

NameThe ideaWhat OWASP and the sources say
bcryptHas a cost setting you raise over timeWork factor at least 10; input limit around 72 bytes in most implementations
scryptSlow, and also needs lots of memoryN=2^17 (128 MiB), r=8, p=1 as a minimum
Argon2idSlow and memory-hungry, the modern pickMinimum 19 MiB memory, 2 iterations, 1 parallelism

Why memory? Special hardware can run thousands of cheap guesses at once, but memory is harder to fit into it. Argon2 is built to be "memory-hard", so each guess needs a big chunk of RAM. RFC 9106 says Argon2id MUST be supported by any implementation, and it's a blend of the two other variants.

All of these have a setting that decides how slow they are. Bcrypt calls it the work factor. Argon2 has memory, iterations and parallelism. More means slower.

How do I tune the knob?

The bcrypt paper says it plainly: the cost should rise as hardware gets better, and users will only tolerate so much delay. So pick the highest setting your server can afford, and check it again every year or so.

Don't copy numbers and forget about them

The OWASP minimums are minimums. RFC 9106 even recommends much bigger settings (like 2 GiB of memory) when the machine can take it. Test on your own server and aim for under a second.

So what would I do differently?

Never invent your own scheme. Use a well-known library, let it make the salt, and choose Argon2id if you can. Bcrypt is fine for older systems.

And remember what a leak really exposes: weak and common passwords go first, strong ones can survive. The hash buys you time. It is not magic. That's why a long, unique password still matters.

Key takeaways
  • A leaked database gives attackers scrambled strings, and they crack them by guessing.
  • Fast hashes make guessing cheap, so password hashes are slow on purpose.
  • A salt stops lookup tables and repeated passwords, but only slowness stops brute force.
  • Use Argon2id (or bcrypt), and raise the cost as hardware improves.

Sources

  • OWASP Password Storage Cheat Sheet
  • RFC 9106: Argon2, the memory-hard function for password hashing
  • Provos, Mazières, A Future-Adaptable Password Scheme, USENIX 1999
ShareXLinkedInEmail
Written by Derpx06A developer who builds AI search tools and the code around them. I explain what I got wrong first, so you can skip it. Spotted a mistake? Tell me — corrections get credited.
Security · 4 minHow do websites remember you're logged in?Foundations · 3 minWhy is 0.1 + 0.2 not 0.3 in code?Foundations · 4 minHow does Git work inside? (Snapshots, not changes)
Start here
01Why is 0.1 + 0.2 not 0.3 in code?02How does Git work inside? (Snapshots, not changes)03How does your computer know the time? (And why it can be wrong)