title: Authenticate a user login with salt
body: <p>I'm using <a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29" rel="nofollow">salt</a> to encrypt my users' passwords.
  I'm using PHP, and here's a quick sample of what happens during a users registers.</p>
  
  <p>Here it is:</p>
  
  <p>PHP code:</p>
  
  <pre><code>    // Gives me my random key. My salt generator.
      $salt = uniqid(mt_rand());
  
      // My password via what users inputs.
      $userpwd;
  
      // Then the encryption. I use a HMAC hash.
      $encrypted = hmac_hash("sha256", $userpwd, $salt);
  ?&gt;
  </code></pre>
  
  <p>Now that all works for me in my script. But my question is, how do I authenticate a user logging in? The new encrypted password is random, so I can't compare the password from the login form to the saved encrypted password in the database.</p>
  
  <p>I've searched and can't find a solution. Maybe I haven't searched hard enough, but is there a way to decrypt the password? What can I do to authenticate the user with my script?</p>