title: Best Practices: Salting & peppering passwords?
body: <p>I came across a discussion in which I learned that what I'd been doing wasn't in fact salting passwords but peppering them, and I've since begun doing both with a function like:</p>
  
  <pre><code>hash_function($salt.hash_function($pepper.$password)) [multiple iterations]
  </code></pre>
  
  <p>Ignoring the chosen hash algorithm (I want this to be a discussion of salts &amp; peppers and not specific algorithms but I'm using a secure one), is this a secure option or should I be doing something different? For those unfamiliar with the terms:</p>
  
  <ul>
  <li><p>A <strong>salt</strong> is a randomly generated value usually stored with the string in the database designed to make it impossible to use hash tables to crack passwords. As each password has its own salt, they must all be brute-forced individually in order to crack them; however, as the salt is stored in the database with the password hash, a database compromise means losing both.</p></li>
  <li><p>A <strong>pepper</strong> is a site-wide static value stored separately from the database (usually hard-coded in the application's source code) which is intended to be secret. It is used so that a compromise of the database would not cause the entire application's password table to be brute-forceable.</p></li>
  </ul>
  
  <p>Is there anything I'm missing and is salting &amp; peppering my passwords the best option to protect my user's security? Is there any potential security flaw to doing it this way?</p>
  
  <p><em>Note: Assume for the purpose of the discussion that the application &amp; database are stored on separate machines, do not share passwords etc. so a breach of the database server does not automatically mean a breach of the application server.</em></p>