A website should never know your password. It only needs to check that you typed the same password you chose at sign-up. That is why passwords are stored as hashes — outputs of a one-way function from which the password cannot be recovered.
Bad ways to store passwords
- Plaintext. Any leak of the database, a backup or a log file exposes every password at once.
- Reversible encryption. Whoever holds the key can decrypt everything. Cisco Type 7 works this way — its key has long been public, and it can be decoded in a fraction of a second.
- Fast unsalted hashes: MD5, SHA-1, SHA-256, NTLM. They are designed to be fast, which is the problem: a GPU tests billions of candidates per second, and identical passwords produce identical hashes.
What the salt is for
A salt is a random string added to the password before hashing and stored next to the hash. Thanks to the salt:
- identical passwords of different users produce different hashes;
- precomputed tables (rainbow tables) become useless;
- every hash has to be attacked separately.
That is why our hash generator gives a new result for the same password every time, yet verification still works.
Slow algorithms
Passwords call for special functions that deliberately slow down every check and use lots of memory. A user waits an extra tenth of a second at login, while an attacker’s guessing becomes thousands of times more expensive.
| Algorithm | Where you see it | Notes |
|---|---|---|
| Argon2id | New applications | OWASP’s first choice; resists GPU cracking |
| scrypt | Cisco Type 9, cryptocurrencies | Memory-hard, good protection |
| bcrypt | PHP, web frameworks, htpasswd | Time-tested; only uses the first 72 bytes of the password |
| yescrypt | Debian, Ubuntu, Fedora ($y$) | The modern /etc/shadow format in many distributions |
| SHA-512 crypt | Linux ($6$) | Widely supported; acceptable with many rounds |
| PBKDF2 | Cisco Type 8, Wi-Fi WPA2, FIPS standards | Needs many iterations; OWASP suggests 600,000+ for SHA-256 |
Cisco network devices
- Type 0 — plaintext, unacceptable.
- Type 7 — reversible encoding (
service password-encryption), only stops shoulder surfing. - Type 5 — MD5-crypt, outdated.
- Type 8 — PBKDF2-SHA256, Type 9 — scrypt. Use these:
username admin algorithm-type scrypt secret …or a ready-made hash withsecret 9 $9$….
Other things that matter
- Pepper — an extra secret stored separately from the database (in configuration or an HSM). If only the database leaks, the hashes can’t be cracked without it.
- Upgrading algorithms. Old hashes can be re-hashed with a stronger algorithm the next time the user logs in successfully.
- Hashes still need protecting. Even a slow hash of a weak password gets cracked. That’s why services check passwords against breach lists and users need long random passwords.
- API keys and tokens aren’t passwords: they are high-entropy random values and can be stored with a fast hash (SHA-256). Create them with the token generator.