The extra ingredient in a password hash

A website should not store passwords in readable form. Instead, it runs each password through a one-way hash function, which turns the password into a fixed-looking result that is practical to calculate but very difficult to reverse. When someone logs in, the site hashes the submitted password and checks whether the result matches the stored one.

A pepper adds a secret ingredient to that calculation. Depending on the system, the password and pepper may be combined before hashing, or the hash may be protected with a keyed cryptographic function. Either way, the pepper changes the result, so a guessed password cannot be checked against the stolen hash without the secret.

Why keep the salt and pepper apart?

A salt is a different, nonsecret value generated for each password and stored with its hash. It ensures that two people using the same password get different stored results, and it makes precomputed lists of password hashes far less useful. But because a salt is in the database, a thief who copies the database can still try password guesses against each account.

The pepper is shared or otherwise managed as a secret outside that database, often in a separate secrets store. The security benefit comes from splitting what an attacker needs across two places: the password records in one, the pepper in another. A database-only theft then does not provide everything needed to test guesses offline.

The operational tradeoff

Separating the secret creates a new responsibility. The application must retrieve or use the pepper when checking logins, so anyone who also compromises the application environment or its secrets may obtain it. The pepper does not replace strong password hashing, unique salts, or protections against guesses made through the login page.

Changing a pepper can also be awkward: the site cannot recalculate existing password hashes without knowing users’ passwords. Systems may therefore need a planned transition, such as updating a hash after a successful login or requiring a password reset. The pepper is useful precisely because it is kept out of the database—but that separation has to be maintained.