Password hashing
Passwords are never stored. The platform stores a hash computed with bcrypt, a function designed specifically for passwords.
What bcrypt is
bcrypt is a cryptographic hash function based on the Blowfish cipher. It is slow and computationally expensive on purpose, which makes brute-force and dictionary attacks impractical. General-purpose functions such as MD5, SHA-1 or SHA-256 are too fast for this use.
Three mechanisms strengthen it:
- A salt. A random value added to the password before hashing. It defeats precomputed tables, and two members with the same password get different hashes.
- A cost factor. It sets how expensive the computation is, and can be raised as hardware gets faster.
- Slow hashing by design.
Reading a bcrypt hash
$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
| Part | Meaning |
|---|---|
$2b$ | bcrypt version |
10 | Cost factor, as a power of two: 2^10 = 1,024 iterations |
N9qo8uLOickgx2ZMRZoMye | The salt, 22 characters |
IjZAgcfl7p92ldGxad68LJZdL17lhWy | The hash, 31 characters |
How it works
- A unique salt is generated for the password.
- The password and the salt are hashed repeatedly, as many times as the cost factor sets.
- The version, the cost, the salt and the hash are stored together as one string, so that a password can be checked later without any other data.