RE: [PHP] GUID or any other unique IDs
| From: | Jasper Bryant-Greene | Date: | Tue, 25 Oct 2005 19:56:38 +0000 |
| Subject: | RE: [PHP] GUID or any other unique IDs | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224655@lists.php.net to get a copy of this message | ||
On Tue, 2005-10-25 at 14:47 +0400, Denis Gerasimov wrote:
> > $unique_id = sha1( uniqid( mt_rand(), true ) );
> >
> > which should be very unique and suitable for most purposes.
>
> I really need millions of unique IDs - hashing is not suitable for this task
> (I think so) :-(. Any more ideas?
The above function could generate much more than millions of unique IDs.
You have 1.46 x 10^48 possible hashes, and with an input of the current
time in microseconds prefixed by a Mersenne Twister random number and
suffixed by additional entropy from the combined linear congruential
generator, collisions should be *very* improbable, even when generating
IDs on multiple hosts all at the same time.
--
Jasper Bryant-Greene
General Manager
Album Limited
e: jasper@album.co.nz
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand