src/LosBase/Service/Uuid.php
private static function generateVersion($namespace, $name, $version)
    {
        if (!self::isValid($namespace)) {
            return false;
        }

        $nhex = str_replace(array('-', '{', '}'), '', $namespace);
        $nstr = '';
        $len = strlen($nhex);

        for ($i = 0; $i < $len; $i += 2) {
            $nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
        }

        if ($version == 3) {
            $hash = md5($nstr.$name);
            $digit = 0x3000;
        } else {
            $hash = sha1($nstr.$name);
            $digit = 0x5000;
        }

        return sprintf('%08s-%04s-%04x-%04x-%12s',
            substr($hash, 0, 8),
            substr($hash, 8, 4),
            (hexdec(substr($hash, 12, 4)) & 0x0fff) | $digit,
            (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
            substr($hash, 20, 12)
        );
    }
private static function generateVersion($namespace, $name, $version)
    {
        if (!self::isValid($namespace)) {
            return false;
        }

        $nhex = str_replace(array('-', '{', '}'), '', $namespace);
        $nstr = '';
        $len = strlen($nhex);

        for ($i = 0; $i < $len; $i += 2) {
            $nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
        }

        if ($version == 3) {
            $hash = md5($nstr.$name);
            $digit = 0x3000;
        } else {
            $hash = sha1($nstr.$name);
            $digit = 0x5000;
        }

        return sprintf('%08s-%04s-%04x-%04x-%12s',
            substr($hash, 0, 8),
            substr($hash, 8, 4),
            (hexdec(substr($hash, 12, 4)) & 0x0fff) | $digit,
            (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
            substr($hash, 20, 12)
        );
    }
private static function generateVersion ( $ namespace , $ name , $ version ) { if ( ! self :: isValid ( $ namespace ) ) { return false ; } $ nhex = str_replace ( array ( '-' , '{' , '}' ) , '' , $ namespace ) ; $ nstr = '' ; $ len = strlen ( $ nhex ) ; for ( $ i = 0 ; $ i < $ len ; $ i += 2 ) { $ nstr .= chr ( hexdec ( $ nhex [ $ i ] . $ nhex [ $ i + 1 ] ) ) ; } if ( $ version == 3 ) { $ hash = md5 ( $ nstr . $ name ) ; $ digit = 0x3000 ; } else { $ hash = sha1 ( $ nstr . $ name ) ; $ digit = 0x5000 ; } return sprintf ( '%08s-%04s-%04x-%04x-%12s' , substr ( $ hash , 0 , 8 ) , substr ( $ hash , 8 , 4 ) , ( hexdec ( substr ( $ hash , 12 , 4 ) ) & 0x0fff ) | $ digit , ( hexdec ( substr ( $ hash , 16 , 4 ) ) & 0x3fff ) | 0x8000 , substr ( $ hash , 20 , 12 ) ) ; }
Generates v3 or v5 UUIDs.

@param string $namespace
@param string $name
@param int    $version

@return bool|string
Generates v3 or v5 UUIDs .