/application/helpers/uuid.php
PHP | 24 lines | 11 code | 2 blank | 11 comment | 0 complexity | 38f08e2336c31382a95141528b359ef3 MD5 | raw file
- <?php
- /**
- * Generate UUIDs
- *
- * @package OpenInterocitor
- * @author l.m.orchard@pobox.com
- * @licence Share and Enjoy
- */
- class uuid_Core
- {
- /**
- * Produce a UUID per RFC 4122, version 4
- * See also: http://us.php.net/manual/en/function.uniqid.php#69164
- */
- public static function uuid() {
- return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
- mt_rand( 0, 0x0fff ) | 0x4000,
- mt_rand( 0, 0x3fff ) | 0x8000,
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
- }
- }