PageRenderTime 31ms CodeModel.GetById 24ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/application/helpers/uuid.php

https://github.com/lmorchard/friendfeedarchiver
PHP | 24 lines | 11 code | 2 blank | 11 comment | 0 complexity | 38f08e2336c31382a95141528b359ef3 MD5 | raw file
 1<?php
 2/**
 3 * Generate UUIDs
 4 *
 5 * @package OpenInterocitor
 6 * @author  l.m.orchard@pobox.com
 7 * @licence Share and Enjoy
 8 */
 9class uuid_Core
10{
11
12    /**
13     * Produce a UUID per RFC 4122, version 4 
14     * See also: http://us.php.net/manual/en/function.uniqid.php#69164
15     */
16    public static function uuid() {
17        return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
18            mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
19            mt_rand( 0, 0x0fff ) | 0x4000,
20            mt_rand( 0, 0x3fff ) | 0x8000,
21            mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
22    }
23
24}