Storing passwords on a server

Servers must keep your credentials safe. Here are three common approaches — and what a hacker actually sees.

Can you find the pattern?

Type anything below and watch what happens to the numbers.

Hash output:

Try typing "ab" and then "ba" — do you get the same number? That's a clue!

Can you still find the pattern?

SHA-256 hash:

Don't be disappointed if you can't see a pattern in the SHA-256 box! That's actually a good thing — real hash functions (like SHA-256) are designed to look completely random. They turn any message into a fixed-length scrambled string (64 hex characters).

Hashes are also one‑way streets: you can't go backward from the hash to the original password, and you can verify this above. And unlike the easy hash above, good hashes make sure different inputs almost never produce the same output.

Now let's see what happens when servers store passwords using different methods.

[01]

No encryption

PLAINTEXT

In this format, passwords are stored without additional encryption or hashing. The server saves the password exactly as the user typed it.

▼ example of stored data "ilovecats123" (alice's password)
[02]

Direct hash

SHA-256

Here, the server runs each password through a hash function (SHA‑256) and stores only the hash. Since hashes are collision-resistant, servers can check authenticity by hashing an entered password, then comparing it with what is stored.

▼ stored hash for "ilovecats123" loading...
[03]

Salted hash

SALT + HASH

A unique random list of characters (a salt) is added to each password before hashing. The server stores both the salt and the hash(salt+password).

▼ example: random salt + stored hash loading...

Test how each method stores a password

[plaintext]

stored as:

[direct hash]

stored hash:

[salted hash]

random salt:
hash(salt+password):

Notice: with salted hash, the same password gives a completely different result each time the salt changes.


Hacker breach simulation

Testing which storage method is most secure by seeing exactly what an attacker discovers after breaking into the database. Each scenario below shows the same breached data, but the damage varies dramatically.

[01]

No encryption — full exposure

The database stores passwords as plain text. The attacker sees every password immediately, and can log in as any user without any cracking effort.

useremailpassword (plaintext)
alicealice@bank.comilovecats123
bobbob@bank.compassword1
charliecharlie@bank.comqwerty2024
[02]

Direct hash — vulnerable to precomputed tables

The server stores hashes. Because the same password always produces the same hash, attackers use precomputed rainbow tables — massive databases mapping common passwords to their hashes — to reverse them instantly.

userSHA-256 hash
aliceloading...
bobloading...
charlieloading...

Try to crack a hash using a rainbow table simulation

🌈 rainbow table snippet (hash prefix → common password)

hash (first 8)password ---"password1" ---"ilovecats123" ---"qwerty2024" ---"admin123" ---"letmein" ---"welcome2024" ---"passw0rd" ---"qwerty123"

Without salt, identical passwords create identical hashes → attackers just look them up.

[03]

Salted hash — resistant to precomputed attacks

Each user has a unique random salt. The hash is computed from salt+password. Even identical passwords produce completely different hashes across users, so precomputed rainbow tables cannot work because the salt changes the hash entirely. Hence, salted hashes, like bcrypt or Argon2, are the modern standard.

usersalthash(salt+password)
alicex9f2kloading...
bobm3p7qloading...
charliew1z8rloading...

Try to guess a password (now near impossible)

Even if you know the correct password, the salt changes the stored hash. An attacker would need to brute-force each user individually — which is extremely expensive.

```