note 110621 deleted from function.uniqid by aharvey
| From: | aharvey@php.net | Date: | Wed, 14 Nov 2012 04:39:27 +0000 |
| Subject: | note 110621 deleted from function.uniqid by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191922@lists.php.net to get a copy of this message | ||
Note Submitter: xianrenb at gmail dot com
----
My way to generate a fairly secure unique id:
<?php
// please add code to read $randomSalt from database/disk here
$randomSalt = (string) hash('sha256', uniqid(mt_rand(), true) . $randomSalt);
// please add code to save $randomSalt to database/disk here
$uniqueId = (string) hash('sha256', uniqid(mt_rand(), true) . $randomSalt);
?>