Glossary

What is password hashing? Storing passwords safely with a one-way transform

Password hashing stores passwords with a one-way transform. How it differs from encryption, why plain MD5 or SHA-256 is unsafe, and why to use bcrypt or Argon2.

Published 2026-06-27 Updated 2026-10-06 7 min read
On this page

You should never store a password as-is in the database. So how do you store it? The answer is hashing. Here's how it works and the key points for doing it safely (no attack steps).

Hashing ≠ encryption

These get confused, but the goals are opposite. Encryption is "reversible with a key, so you can read it back later." Hashing is "one-way — you can't reverse it." A password is information even the operator shouldn't need to read back, so a deliberately irreversible hash is the right fit.

Encryption (reversible)

plaintext ⇄ ciphertext. key reverses it. for data you read back

Hashing (one-way)

password → hash. can't be reversed. for storing passwords

Store passwords with a one-way hash. Encryption (reversible) has the opposite goal.

At login, you check "hash the entered password the same way and see if it matches the stored hash." You never need to recover the original.

Why "raw MD5/SHA-256" isn't enough

MD5 and SHA-256 are fast hashes. That's a useful property elsewhere, but a weakness for password storage: an attacker can compute a huge number of guesses per second against a leaked hash.

  • Rainbow tables: a giant precomputed table of "common password → its hash." With a raw hash, a match is found just by looking it up.
  • Brute force: the faster the hash, the more guesses per unit time — i.e. the easier to crack.

General-purpose hashes vs password hashes

Both are called "hashes," but they were built for different jobs. Only the right-hand column belongs in password storage.

General-purpose hash (MD5, SHA-1, SHA-256)Password hash (Argon2id, bcrypt, scrypt, PBKDF2)
Built forDetecting file tampering, signatures, etc.Storing passwords
SpeedAs fast as possibleDeliberately slow (tunable)
SaltNot part of the designPart of the design (PBKDF2 takes it from the caller)
Tuning the costNot possibleCost, iterations, or memory; raised over time
For password storageDon't useUse

NIST SP 800-63B-4 likewise requires passwords to be stored with a password hashing scheme that takes a salt and a cost factor as inputs, with the cost set as high as practical without hurting performance and increased over time.

The two safeguards

1

Add a salt (a different value per user)

Before hashing, mix in a random value that differs per user (a salt). Now the same password stores differently for everyone, which defeats rainbow tables and stops one cracking run from covering reused passwords across accounts.

2

Use a deliberately slow, purpose-built hash

bcrypt / Argon2 / scrypt let you make the computation intentionally expensive (a cost parameter). A slowness no one notices for a single legitimate login drops the attacker's brute force to an impractical rate. Salting is built into these too.

Real cases: when a breach notice says "hashed"

Breach announcements sometimes say whether passwords were stored in plaintext, hashed, or encrypted. Here are cases this site has covered, arranged by storage method.

CaseWhat was disclosed about passwordsWhat it means for users
Takufile-bin (2019)Stored in plaintextReadable as-is. Other services using the same password are at risk too
Sakura Internet (2026)Some initial passwords were not hashedAnyone still using an initial password needs to change it now
Gyazo (2026)Password hashes leaked; method not disclosedMay be reversible depending on the method. The company asked users to change passwords

Two things to keep in mind when reading a notice:

  • "Hashed" alone doesn't tell you whether it's safe. Raw MD5 and a salted slow hash differ enormously in how easily passwords can be recovered
  • If the method isn't stated, act as if it was weak. Change the password on that service and on any other service where you use the same one

You can check whether your email address appears in past breaches with how to check if your password was leaked.

How to check your own site and accounts

1

As a user: watch how password reset works

If "forgot password" emails you your original password, the service is very likely storing it in plaintext or a reversible form. Don't use a password there that you use anywhere else.

2

As a user: check your password's strength

Hashing protects long, hard-to-guess passwords best. Check a rough strength estimate with the password strength checker, and leave storage to a password manager.

3

As a developer: check which function stores passwords

Find the functions your code uses to store and verify passwords. PHP's password_hash(), Django's built-in auth, or a bcrypt/Argon2 library are password-specific and cover the basics. Any direct call to md5(), sha1(), or sha256 is a migration target.

4

As a developer: check stored values and settings

How to identify stored hashes, OWASP's minimum settings, and how to migrate off weak algorithms are covered in how to store passwords safely.

This site's view: don't build it yourself

Assuming "MD5 plus a salt is enough" is a common mistake. Safe password storage also depends on generating and storing the salt, tuning the cost, and handling timing differences. Rather than assembling that yourself, lean on your language/framework's official password function (most use bcrypt/Argon2 under the hood). For new systems, make Argon2id your first choice.

Sources (primary)

  • NIST, "SP 800-63B-4 Digital Identity Guidelines: Authentication and Authenticator Management" (August 2025) — pages.nist.gov (hashing schemes that take a salt and a cost factor; raising the cost over time)
  • OWASP, "Password Storage Cheat Sheet" — cheatsheetseries.owasp.org (hashing vs encryption, recommended algorithms, work factor)
  • RFC 9106, "Argon2 Memory-Hard Function for Password Hashing and Proof-of-Work Applications" — rfc-editor.org
  • Sources for each case (the companies' own announcements) are listed in the linked articles on this site

Classification

CWE classifies the types of weakness behind vulnerabilities; MITRE ATT&CK classifies attacker techniques. Both are maintained by MITRE and widely used to label vulnerability reports and detection rules.

CWE™: Copyright © 2006–2026, The MITRE Corporation. CWE is a trademark of The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE Terms of Use

© 2026 The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. MITRE ATT&CK and ATT&CK are registered trademarks of The MITRE Corporation. The MITRE Corporation (MITRE) hereby grants you a non-exclusive, royalty-free license to use ATT&CK® for research, development, and commercial purposes. Any copy you make for such purposes is authorized provided that you reproduce MITRE's copyright designation and this license in any such copy. ATT&CK Terms of Use

FAQ

QHow is hashing different from encryption?
A

Encryption is reversible: with the key you can decrypt the data back, which is what you want for data you'll read again. Hashing is one-way — you can't reverse it. A password doesn't actually need to be readable back, even by you, so a deliberately irreversible hash fits. Even if the database is stolen, you can't pull the original passwords straight out of the hashes.

QIs hashing with MD5 or SHA-256 safe enough?
A

No, not on its own. MD5/SHA-256 are 'fast' hashes, so an attacker can test an enormous number of guesses per second, and common passwords fall to brute force or rainbow tables (precomputed lookup tables). To make it safe, add a per-user 'salt' and use a deliberately slow, purpose-built hash (bcrypt, Argon2, or scrypt).

QWhich one should I actually use?
A

For new systems Argon2 (Argon2id especially) is the first choice, with bcrypt or scrypt as solid alternatives. All of them build salting and a tunable cost factor into the design. Rather than wiring up MD5+salt yourself, use these standard implementations (your language/framework's official functions) — it's safer and more reliable.

QCan a hashed password be cracked?
A

A hash can't be computed back into the password. But candidate passwords can be hashed the same way and checked for a match. That makes short or common passwords easy to find, especially when the algorithm is fast. If the password is long, not reused, and stored with a salted slow hash, finding it is impractical.

QWhy won't a service tell me my old password when I forget it?
A

Because a service that hashes correctly doesn't have your original password either. That's why the process is a reset (you choose a new one). Conversely, a service that emails you your original password is very likely storing it in plaintext or in a reversible form.

QShould I change my password if a company says password hashes leaked?
A

Yes. Companies often don't disclose the hashing method, and a weak method can be reversed. Also change it on any other service where you use the same or a slightly modified password.