note 110621 added to function.uniqid
| From: | xianrenbatgmaildotcom | Date: | Wed, 14 Nov 2012 04:35:42 +0000 |
| Subject: | note 110621 added to function.uniqid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191921@lists.php.net to get a copy of this message | ||
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);
?>
----
Server IP: 180.92.182.149
Probable Submitter: 124.244.171.10
----
Manual Page -- http://www.php.net/manual/en/function.uniqid.php
Edit -- https://master.php.net/note/edit/110621
Del: integrated -- https://master.php.net/note/delete/110621/integrated
Del: useless -- https://master.php.net/note/delete/110621/useless
Del: bad code -- https://master.php.net/note/delete/110621/bad+code
Del: spam -- https://master.php.net/note/delete/110621/spam
Del: non-english -- https://master.php.net/note/delete/110621/non-english
Del: in docs -- https://master.php.net/note/delete/110621/in+docs
Del: other reasons-- https://master.php.net/note/delete/110621
Reject -- https://master.php.net/note/reject/110621
Search -- https://master.php.net/manage/user-notes.php