note 64495 deleted from function.uniqid by googleguy

From: Date: Tue, 15 Jan 2013 05:09:42 +0000
Subject: note 64495 deleted from function.uniqid by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193066@lists.php.net to get a copy of this message
Note Submitter: maciej dot strzelecki at gmail dot com ---- This is an implementation of version 4 UUID, which is generating UUIDs from truly-random numbers. <?php /* Copyright 2006 Maciej Strzelecki This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ function uuid() { // version 4 UUID return sprintf( '%08x-%04x-%04x-%02x%02x-%012x', mt_rand(), mt_rand(0, 65535), bindec(substr_replace( sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4) ), bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)), mt_rand(0, 255), mt_rand() ); } ?>

« previous php.notes (#193066) next »