CodePark/ questions / Passwords, hashing & MFA
START PRACTICINGPRACTICE
Backend question · Auth & security › Passwords, hashing & MFA

How do a salt and a pepper differ in password storage?

A salt is unique per password and stored with the hash; a pepper is one secret applied to all hashes and kept outside the database, for example in a secrets manager or HSM

A salt is unique per password and stored with the hash. A pepper is one secret used for all hashes and kept outside the database.

Salts don't need to be secret. Their job is to make every hash unique. Then precomputed tables fail, and attackers can't crack many users at once.


A pepper adds a secret that the attacker doesn't have when only the database leaks. It works only if you store it somewhere else, like a secrets manager or an HSM (hardware security module). A pepper is an optional extra. It never replaces a salt, so "A pepper replaces the salt when using Argon2id" is wrong. "A salt is secret and kept in an HSM" is also wrong: it swaps the two roles.