note 104492 added to function.uniqid

From: Date: Fri, 17 Jun 2011 19:40:03 +0000
Subject: note 104492 added to function.uniqid
Groups: php.notes 
Request: Send a blank email to php-notes+get-180650@lists.php.net to get a copy of this message
mt_rand() features in a lot of comments here. It is a good PRNG for Monte Carlo simulations, not for anything related to security. Wikipedia's page on cryptographically-secure PRNGs explains. If you want it to be hard for an attacker to guess or predict a "random" UUID, try using /dev/random instead. <?php $r = unpack('v*', fread(fopen('/dev/random', 'r'),16)); $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', $r[1], $r[2], $r[3], $r[4] & 0x0fff | 0x4000, $r[5] & 0x3fff | 0x8000, $r[6], $r[7], $r[8]); ?> That's obviously not production code. It's just for illustration. ---- Server IP: 69.147.83.197 Probable Submitter: 75.69.144.42 ---- Manual Page -- http://www.php.net/manual/en/function.uniqid.php Edit -- https://master.php.net/note/edit/104492 Del: integrated -- https://master.php.net/note/delete/104492/integrated Del: useless -- https://master.php.net/note/delete/104492/useless Del: bad code -- https://master.php.net/note/delete/104492/bad+code Del: spam -- https://master.php.net/note/delete/104492/spam Del: non-english -- https://master.php.net/note/delete/104492/non-english Del: in docs -- https://master.php.net/note/delete/104492/in+docs Del: other reasons-- https://master.php.net/note/delete/104492 Reject -- https://master.php.net/note/reject/104492 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180650) next »