Skip to content

Password salting

Password salting gives each new password hash its own random additional value. The salt is stored alongside it and does not need to be secret.

IT security

Use a separate salt for each password hash

Password salting gives every newly created password hash a separate, securely generated random additional value. The salt is an input to the password hash function. It does not need to be secret and is stored with the verification value. A correctly used password hashing library can handle generation and management.

In a fictional application, account-A and account-B choose the same password. The library generates independent random salts for them. The labels salt-A and salt-B stand only for those values here; they are not usable salt settings. Different salts prevent an attacker from simply reusing a precomputed hash across all accounts.

Use the stored value when verifying

At a later sign-in, the library uses the stored salt and parameters to check the entered password. It does not generate a new salt every time it verifies an existing password hash. Creating a new password hash, however, uses a fresh salt.

A salt is not a pepper: a pepper is an additional secret that can protect multiple password records and is kept separately from the password database. A salt also does not replace a sufficiently costly password hash function. Someone holding a database copy can still try candidate passwords with the respective salt; weak passwords therefore remain at risk.

Sources