Aprelius logo
uptime: 00:00:00
CyberSecurity

Password Hashing and Storage

General-purpose hashes like SHA-256 are built for speed, which makes them a poor fit for storing passwords — an attacker can try billions of guesses per second. Password hashing uses algorithms deliberately designed to make each password guess expensive, using CPU time, memory, or both.

Password-hashing algorithms

  • Argon2 — winner of the Password Hashing Competition, the default recommendation for new systems
  • scrypt — memory-hard, resistant to specialised hardware
  • bcrypt — long-established, based on the Blowfish cipher
  • PBKDF2 — standards-compliant key derivation function

Each takes a cost parameter (how much work per hash) and a salt — random data mixed into the password so identical passwords produce different hashes.

Linux: /etc/shadow

Hashes live in /etc/shadow, readable only by root. Each hash field has the form:

text
$algorithm$parameters$salt$hash
PrefixAlgorithmStatus
$y$yescryptcurrent default, recommended
$6$sha512cryptwidely supported
$2b$bcryptstrong alternative
$1$md5cryptlegacy, avoid

Example entry:

text
user:$y$j9T$76UzfgEM5PnymhQ7TlJey1$/OOSg64dhfF.TigVPdzqiFang6uZA4QA1pzzegKdVm4:19965:0:99999:7:::
  • y — yescrypt
  • j9T — cost parameters
  • 76UzfgEM5PnymhQ7TlJey1 — salt
  • /OOSg64dhfF.TigVPdzqiFang6uZA4QA1pzzegKdVm4 — hash

Windows: SAM and NTLM

Windows hashes passwords with NTLM (based on MD4) and stores them in the Security Accounts Manager (SAM) database, or in NTDS.dit on a domain controller. NT hashes look like MD4/MD5 hashes, so context matters for identification.

Tools like Mimikatz extract them. Attackers commonly use pass-the-hash rather than cracking the password itself.

Glossary

Salt

Random data combined with a password before hashing. It makes identical passwords hash differently and defeats precomputed rainbow table lookups.

Rainbow table

A precomputed table mapping hashes back to inputs, used to reverse unsalted password hashes quickly.

Pass the hash

Authenticating to a service by presenting a captured NT hash directly, without ever knowing or cracking the plaintext password.

Reference

Hashcat example hashes