Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update, March 2014:</strong></p> <p>Firstly, it is important to note that <code>uniqid</code> is a bit of a misnomer as it doesnt guarantee a unique ID.</p> <p>Per the <a href="http://php.net/uniqid" rel="noreferrer">PHP documentation</a>:</p> <blockquote> <p><strong>WARNING!</strong></p> <p>This function does not create random nor unpredictable string. This function must not be used for security purposes. Use cryptographically secure random function/generator and cryptographically secure hash functions to create unpredictable secure ID.</p> </blockquote> <p>And</p> <blockquote> <p>This function does not generate cryptographically secure tokens, in fact without being passed any additional parameters the return value is little different from <a href="http://www.php.net/manual/en/function.microtime.php" rel="noreferrer">microtime()</a>. If you need to generate cryptographically secure tokens use <a href="http://www.php.net/manual/en/function.openssl-random-pseudo-bytes.php" rel="noreferrer">openssl_random_pseudo_bytes()</a>.</p> </blockquote> <hr> <p>Setting more-entropy to true generates a more unique value, however the execution time is longer (though to a tiny degree), according to the docs:</p> <blockquote> <p>If set to TRUE, uniqid() will add additional entropy (using the combined linear congruential generator) at the end of the return value, which increases the likelihood that the result will be unique.</p> </blockquote> <p>Note the line <code>increases the likelihood that the result will be unique</code> and not that is will <em>guarantee</em> uniqueness.</p> <p>You can 'endlessly' strive for uniqueness, up to a point, and enhance using any number of encryption routines, adding <a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29" rel="noreferrer">salts</a> and the like- it depends on the purpose.</p> <p>I'd recommend looking at the comments on the main PHP topic, notably:</p> <p><a href="http://www.php.net/manual/en/function.uniqid.php#96898" rel="noreferrer">http://www.php.net/manual/en/function.uniqid.php#96898</a></p> <p><a href="http://www.php.net/manual/en/function.uniqid.php#96549" rel="noreferrer">http://www.php.net/manual/en/function.uniqid.php#96549</a></p> <p><a href="http://www.php.net/manual/en/function.uniqid.php#95001" rel="noreferrer">http://www.php.net/manual/en/function.uniqid.php#95001</a></p> <p>What I'd recommend is working out <em>why</em> you need uniqueness, is it for security (i.e. to add to an encryption/scrambling routine)? Also, <em>How</em> unique does it need to be? Finally, look at the speed consideration. Suitability will change with the underlying considerations.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload