password hashes

created onSeptember 15, 2026

the structure of password hashes

A hash has three or four components delimited by special characters like :

  • the hash algorithm.
  • a cost/work factor – this is an integer that specifies the iteration count, making the hashing deliberately even more compute intensive in order to prevent brute force attacks.
  • a salt value – this value is appended to the password and the resulting string is hashed. This ensures, that two passwords that are exactly the same result in different password hashes, thus preventing brute force attacks with pre-computed hash values (a.k.a. rainbow tables).
  • the hash value of the password/salt combination.

Some password hashes, i.e., those stored in Linux’ password file, do not contain a cost/work factor field.

The cool thing about hashes is that for a given hash algorithm, any arbitrary input of any arbitrary length results in a hash of the algorithm-specific hash length, i.e., 265 bit for SHA-512.

some hash algorithm identifiers

identifier hash algorithm digest length
1 MD5 128
2 Blowfish, 1999, original spec. 184
2a Blowfish, correctly handling non-ASCII characters and null terminators 184
x, y Blowfish, 2011, bugfix in PHP’s crypt_blowfish 184
2b Blowfish, 2014, bugfix for OpenBSD implementation of Blowfish 184
3 Eksblowfish 184
4 NT 128
5 SHA-256 256
6 SHA-512 512
x