note 33254 added to function.uniqid

From: Date: Fri, 20 Jun 2003 09:24:55 +0000
Subject: note 33254 added to function.uniqid
Groups: php.notes 
Request: Send a blank email to php-notes+get-50708@lists.php.net to get a copy of this message
I have ported libuuid(3), which provides unique identifiers for C programs on Linux, to PHP. libuuid uses /dev/urandom as a source of random data. If /dev/urandom isn't available, the returned value is based on the current time and on data generated with the mt_rand() function (which in turn is seeded with the current time, PID, and UID). The C version is part of the e2fsprogs package. The number it generates is 128 bits long. The PHP version can be downloaded at: http://www.notreached.net/php-uuid-1.23.tar.gz In your code, write: <?php require_once('uuid.php'); // Returns a binary format $unique_id = uuid_generate(); // Two ways two make it a 7-bit string usable in a cookie: // 36-byte hyphenated, hexadecimal format compatible with // the OSF Distributed Computing Environment utility 'uuidgen': $osf_dce_format = uuid_unparse($unique_id); // Base64 encoded. 24 bytes. $base64 = base64_encode($unique_id); ?> ---- Manual Page -- http://www.php.net/manual/en/function.uniqid.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33254 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33254&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33254&report=yes

« previous php.notes (#50708) next »