Store user passwords safely with salting and slow hashes, and handle resets well.
Password management is how a system stores and checks its users' passwords so that a stolen database does not hand attackers the passwords.
When a user signs up, the server must later be able to tell whether a typed password is right. It does not need to know the password to do that. It only needs to be able to check it. A hash function makes this possible: it turns the password into a fixed-size value, and you cannot run it backwards. At login, the server hashes what the user typed and compares the result with the stored value.
But not every hash is good for passwords. General-purpose hashes (like plain SHA-256 or MD5) are built to be fast, and fast is exactly what an attacker wants: a stolen table can be attacked with a huge number of guesses per second. Password hashes such as Argon2id, bcrypt and scrypt are built to be slow (and some use a lot of memory), with a setting you can raise over time. That multiplies the cost of every guess.
A salt is a random value, unique per user, stored next to the hash and mixed into it. Two users with the same password end up with different hashes, and an attacker cannot reuse one precomputed table of common passwords against everyone. An optional pepper is a further secret kept outside the database (for example in a secret manager), so a stolen database alone is not enough to start guessing.
| Method | What an attacker with the table can do | Verdict |
|---|---|---|
| Plain text | Read every password at once | Never |
| Reversible encryption | Decrypt every password if they also get the key, which lives close by | Never. The system should not be able to recover passwords. |
| Fast hash, no salt (plain SHA-256, MD5) | Look up common passwords in precomputed tables, spot shared passwords, and guess very fast | Not acceptable |
| Fast hash + salt | Cannot use shared tables, but can still guess very fast | Not good enough for passwords |
| Slow salted hash: Argon2id, bcrypt, scrypt | Must guess one password at a time, and each guess is costly | Use this |
| Slow salted hash + pepper in a secret manager | Cannot even start guessing without the pepper | Best, with more moving parts |
| Algorithm | What makes it slow | Notes |
|---|---|---|
| Argon2id | Time and a lot of memory, which resists special hardware | A modern first choice for new systems |
| scrypt | Time and memory | Well respected, and a good option if Argon2id is not available |
| bcrypt | Time (a cost factor) | Widely supported and still acceptable, with a limit on very long passwords in many versions |
The password itself is stored. Anyone who reads the table reads every password.
Toy hash for teaching only. It is not real cryptography.
Guess speeds are made-up illustrative numbers for a well-equipped attacker, to show the shape and not to predict real attacks. Real people pick predictable passwords (names, words, patterns), which are guessed far sooner than random ones. That is why length, breach checks and slow hashes all matter.
| Term | Meaning in easy words |
|---|---|
| Hash function | A one-way function that turns input into a fixed-size value that cannot be reversed |
| Password hash | A deliberately slow hash made for storing passwords, such as Argon2id, bcrypt or scrypt |
| Salt | A unique random value per user, mixed into the hash and stored beside it |
| Pepper | A secret value kept outside the database and mixed into every hash |
| Cost factor | A setting that controls how slow (and costly to attack) the hash is |
| Rainbow table | A precomputed list of hashes for common passwords. Unique salts make it useless |
| Brute force | Trying many passwords one after another until one works |
| Credential stuffing | Trying passwords leaked from other sites against your login |
| Rate limiting | Slowing or blocking repeated attempts from one account or address |
| MFA | Multi-factor authentication: a second proof besides the password |
| Passkey | A passwordless sign-in method based on public-key cryptography |
| Choice | We gain | We lose |
|---|---|---|
| Higher cost factor | Each guess costs the attacker more | Slower logins and more server load |
| Lower cost factor | Fast logins, cheap servers | Cheaper guessing for an attacker |
| Adding a pepper | A stolen database is not enough to guess | A secret to manage, and rotating it is harder |
| Strict composition rules | Looks safe | Users pick predictable patterns. Length and breach checks work better |
| Account lockout | Stops online guessing | Attackers can lock real users out on purpose. Prefer rate limits and delays |
| Login with an identity provider | No passwords to store | A dependency, and less control over the sign-in experience |