note 39306 added to function.rand

From: Date: Fri, 23 Jan 2004 21:49:41 +0000
Subject: note 39306 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-64084@lists.php.net to get a copy of this message
Note that md5() does not make a random number any more likely to be unique. md5() is a deterministic function, meaning md5(x) == md5(x) for any value of x. If it didn't work that way, it wouldn't do things that it is supposed to do, like encode the same password at two different times and create the same two results. In the same way, md5(rand())will give you the same result if, by chance, the same random number comes out of rand(). Also md5(time()) will generate the same result if it is executed twice in the same second (ie time() gives the same result). The only result of running these things through md5 is to hide to original number, thus hiding, for example (for reasons I cannot imagine) that you are using the time, or possibly the range of your selection of random numbers. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39306 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39306&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39306&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64084) next »