Storing a password without storing it
Never store in plaintext: hashing
A website does not know your password, and that is intentional. Understanding why is the starting point for all account security.
Never store in plaintext
The absolute rule: a service must never keep passwords in plaintext in its database. If that database leaks — theft, SQL injection, malicious employee — the attacker would immediately obtain every password. And since many people reuse the same one everywhere, they could also empty out their mailbox, their social media, their bank account.
Massive breaches are common: entire databases end up for sale. Storing in plaintext turns a simple leak into a total catastrophe.
The idea: store the hash
The solution relies on a hash function. Such a function transforms any text into a fixed-size hash, and has two key properties:
- it is deterministic: the same password always produces the same hash;
- it is one-way: from the hash, you cannot go back to the password.
The site therefore stores only the hash, never the password.
motdepasse123 --[ hashing ]--> ef92b778ba... (hash)
Sign-up and login
The mechanism happens in two stages.
SIGN-UP
user types : "chat2024"
site computes : h = hash("chat2024")
site stores : h (the password is discarded)
LOGIN
user types : "chat2024"
site computes : h' = hash("chat2024")
site compares : h' == h ?
equal -> login accepted
different -> rejected
The site verifies the password without ever knowing it. It only compares two hashes. Even the administrator, reading the database, sees only unreadable hashes.
The problem: functions that are too fast
This first solution has a weakness. Classic hash functions like SHA-256 are designed to be very fast: that is an asset for verifying a file, but a flaw here.
An attacker who obtains the database of hashes can try passwords offline, at will. With ordinary hardware, a graphics card computes billions of SHA-256 hashes per second. They then test entire lists of passwords and compare each hash to the stolen ones.
In other words: hashing is necessary, but not sufficient. The speed of SHA-256 works against us. The next two lessons show the precise attacks, then the modern defenses.
In summary
- You never store a password in plaintext; you store its hash.
- The hash function is deterministic and one-way.
- At login, you hash the entered password and compare the hashes.
- A fast hash like SHA-256 allows billions of attempts per second: insufficient on its own.

