当前位置: 首页>>代码示例>>PHP>>正文


PHP UUID::v5方法代码示例

本文整理汇总了PHP中UUID::v5方法的典型用法代码示例。如果您正苦于以下问题:PHP UUID::v5方法的具体用法?PHP UUID::v5怎么用?PHP UUID::v5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UUID的用法示例。


在下文中一共展示了UUID::v5方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 public static function create($type, $name)
 {
     //get or create namespace uuid for Group-Office
     $namespace = \GO::config()->get_setting('uuid_namespace');
     if (!$namespace) {
         $namespace = UUID::v4();
         \GO::config()->save_setting('uuid_namespace', $namespace);
     }
     return UUID::v5($namespace, $type . $name);
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:10,代码来源:UUID.php

示例2: test_v5_sha1

 /**
  * Tests UUID::v5()
  *
  * @test
  * @dataProvider provider_v5_sha1
  * @covers UUID::v5
  * @param  string  $value     value to generate UUID from
  * @param  string  $expected  UUID
  */
 public function test_v5_sha1($value, $expected)
 {
     $this->assertEquals($expected, UUID::v5(UUID::NIL, $value));
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:13,代码来源:UUIDTest.php

示例3: getTempFilename

/**
* 
*  getTempFilename - HelperFunction
* 
* @param string $url
* @param string $NS
* 
* @return
*/
function getTempFilename($url, $NS = '09c8637d-64f7-5eed-a80a-07a59059c47c')
{
    //1.3.6.1.4.1.37553.8.1.8.8.5.65.1
    return sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'download.zip.' . mt_rand(1000, 9999) . '.' . UUID::v3($NS, $url) . '.' . UUID::v5($NS, $url) . '.' . UUID::v4() . '.' . 'zip';
}
开发者ID:frdl,项目名称:webfan,代码行数:14,代码来源:Component.php

示例4: set_include_path

<?php

namespace cd;

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/');
require_once 'UUID.php';
$v3 = UUID::v3('514d2ee9-58ed-49ef-a592-1a49c268e2a2', 'test crap 123');
if ($v3 != "19d179a2-9511-3595-a8e2-490b981e92c2") {
    echo "FAIL 1\n";
}
$v5 = UUID::v5('514d2ee9-58ed-49ef-a592-1a49c268e2a2', 'test crap 123');
if ($v5 != "f1b18651-7633-5945-8527-853ddc5b6393") {
    echo "FAIL 2\n";
}
$v4 = UUID::v4();
echo "UUID v3 (md5):  " . $v3 . "\n";
echo "UUID v5 (sha1): " . $v5 . "\n";
echo "UUID v4 (rand): " . $v4 . "\n";
$hex = UUID::toHex('3F2504E0-4F89-11D3-9A0C-0305E82C3301');
if ($hex != 'E004253F894FD3119A0C0305E82C3301') {
    echo "FAIL 3\n";
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:22,代码来源:test.UUID.php

示例5: tagBegin

 /** Creates iCalendar begin tag */
 private function tagBegin($obj, $s = '')
 {
     $res = "BEGIN:" . $obj . "\r\n";
     switch ($obj) {
         case 'VCALENDAR':
             $uuid = UUID::v5('7c7884bf-14f8-478a-ab0e-778a6ac1d437', $this->name);
             $res .= "VERSION:2.0\r\n" . "PRODID:-//" . $this->prod_id . "//NONSGML v1.0//EN\r\n" . "X-WR-CALNAME:" . $s . "\r\n" . ($this->desc ? "X-WR-CALDESC:" . $this->desc . "\r\n" : '') . "X-WR-TIMEZONE:" . $this->timezone . "\r\n" . "X-WR-RELCALID:" . $uuid . "\r\n" . "CALSCALE:GREGORIAN\r\n" . "METHOD:PUBLISH\r\n";
             // XXX ??? snodde från googles kalender
             break;
         case 'VEVENT':
             break;
     }
     return $res;
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:15,代码来源:iCalendarWriter.php

示例6: sprintf

    {
        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, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
    }
    public static function v5($namespace, $name)
    {
        if (!self::is_valid($namespace)) {
            return false;
        }
        // Get hexadecimal components of namespace
        $nhex = str_replace(array('-', '{', '}'), '', $namespace);
        // Binary Value
        $nstr = '';
        // Convert Namespace UUID to bits
        for ($i = 0; $i < strlen($nhex); $i += 2) {
            $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
        }
        // Calculate hash value
        $hash = sha1($nstr . $name);
        return sprintf('%08s-%04s-%04x-%04x-%12s', substr($hash, 0, 8), substr($hash, 8, 4), hexdec(substr($hash, 12, 4)) & 0xfff | 0x5000, hexdec(substr($hash, 16, 4)) & 0x3fff | 0x8000, substr($hash, 20, 12));
    }
    public static function is_valid($uuid)
    {
        return preg_match('/^\\{?[0-9a-f]{8}\\-?[0-9a-f]{4}\\-?[0-9a-f]{4}\\-?' . '[0-9a-f]{4}\\-?[0-9a-f]{12}\\}?$/i', $uuid) === 1;
    }
}
// Usage
// Named-based UUID.
$v3uuid = UUID::v3('1546058f-5a25-4334-85ae-e68f2a44bbaf', 'SomeRandomString');
$v5uuid = UUID::v5('1546058f-5a25-4334-85ae-e68f2a44bbaf', 'SomeRandomString');
// Pseudo-random UUID
$v4uuid = UUID::v4();
开发者ID:aqidd,项目名称:Rester,代码行数:31,代码来源:UUID.php

示例7: Create

 public static function Create()
 {
     return UUID::v5(UUID::v4(), uniqid());
 }
开发者ID:iensenfirippu,项目名称:securipe,代码行数:4,代码来源:UUID.php

示例8: buildSoapHeaders

 public function buildSoapHeaders()
 {
     $timeStamp = gmdate("Y-m-d\\TH:i:s\\Z");
     $requestId = UUID::v5($this->uuidNameSpace, $timeStamp);
     if (false === $requestId) {
         throw new Exception("Failed to generate the mandatory UUID");
     }
     $payzenSoapHeaders = array('shopId' => $this->payzenAccount['shopId'], 'requestId' => $requestId, 'timestamp' => $timeStamp, 'mode' => $this->payzenAccount['mode'], 'authToken' => $this->buildAuthToken($requestId, $timeStamp));
     $soapHeaders = array();
     foreach ($payzenSoapHeaders as $header => $value) {
         $soapHeaders[] = new SOAPHeader($this->payzenAccount['ns'], $header, $value);
     }
     return $soapHeaders;
 }
开发者ID:payzen,项目名称:soap-v5-payment-exemple-php,代码行数:14,代码来源:payzenSoapV5ToolBox.php


注:本文中的UUID::v5方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。