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

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:

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.

AlgorithmWhere you see itNotes
Argon2idNew applicationsOWASP’s first choice; resists GPU cracking
scryptCisco Type 9, cryptocurrenciesMemory-hard, good protection
bcryptPHP, web frameworks, htpasswdTime-tested; only uses the first 72 bytes of the password
yescryptDebian, Ubuntu, Fedora ($y$)The modern /etc/shadow format in many distributions
SHA-512 cryptLinux ($6$)Widely supported; acceptable with many rounds
PBKDF2Cisco Type 8, Wi-Fi WPA2, FIPS standardsNeeds many iterations; OWASP suggests 600,000+ for SHA-256
OWASP baseline for new systems: Argon2id with 19 MiB of memory and 2 iterations; if unavailable, scrypt, bcrypt with a cost of 10 or more, or PBKDF2-HMAC-SHA256 with 600,000 iterations.

Cisco network devices

Other things that matter