title: How do you create "good" random md5 hashes in php?
body: <p>For several cases I would need to create random md5 hashes. Do you know what the best / most secure ways of doing this are?</p>
  <h3>Some use cases</h3>
  <ul>
  <li>Verifying an email address</li>
  <li>Resetting passwords</li>
  <li>Some kind of session id used for authentication, instead of password (eg: when someone hits &quot;remember me&quot;, I would not like to store the pass in a cookie)</li>
  </ul>
  <h3>Background</h3>
  <p>I know that <code>rand()</code> should not be used for security relevant applications. For that reason I went with:</p>
  <pre><code>md5( uniqid(mt_rand(),true) );
  </code></pre>
  <p>Now I read in the <a href="http://at2.php.net/manual/en/function.uniqid.php" rel="nofollow noreferrer">php manual</a> about <code>uniqid()</code>, that it <em>must not be used for security purposes</em>. Which kind of makes sense because it usually just gives something like a timestamp.</p>
  <p>But is it fine when combined with a random prefix - <code>mt_rand()</code> - like I do, or is there something better that should be used in this case?</p>
  <p>Thx in advance!</p>