Password Storage: The Decisions That Matter
How applications store user passwords so that a database breach does not reveal them, using slow, salted password hashing algorithms.
On this page
What is at stake
Passwords stored with fast hashes or encryption are cracked quickly after a breach, exposing users who reuse them elsewhere.
The playbook
- Use the framework's built-in password hashing
- Choose Argon2id or bcrypt with appropriate cost settings
- Rehash passwords when algorithms or costs are upgraded
- Rate-limit login attempts
- Offer multi-factor authentication
Where it goes wrong
Avoid:
- Custom password hashing schemes
- Encrypting passwords so they can be decrypted
- Emailing passwords to users
- Logging passwords in error logs
The numbers behind it
| Measure | Figure |
|---|---|
| OWASP recommendation | Argon2id, with scrypt and bcrypt as alternatives |
| Salting | a unique salt per password, handled by modern algorithms |
| Never | store passwords in plain text or with fast hashes such as MD5 or SHA-1 |
| Frameworks | Laravel, PHP and Node.js libraries provide built-in password hashing |
Getting outside help
When to hand it over: Bring in help when inheriting a legacy system with weak password storage, or after a suspected breach.
Where this comes from
- OWASP — Password Storage Cheat Sheet
- PHP Manual — password_hash
The figures and practices above come from the sources listed.
Working on something like this?
We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.