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


PHP UUID::randomSource方法代码示例

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


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

示例1: initRandom

 public static function initRandom()
 {
     /* Look for a system-provided source of randomness, which is usually crytographically secure.
        /dev/urandom is tried first because tests suggest CAPICOM is quite slow to initialize. */
     if (is_readable('/dev/urandom')) {
         self::$randomSource = fopen('/dev/urandom', 'rb');
         self::$randomFunc = 'randomFRead';
     } else {
         if (class_exists('COM', 0)) {
             try {
                 self::$randomSource = new COM('CAPICOM.Utilities.1');
                 // See http://msdn.microsoft.com/en-us/library/aa388182(VS.85).aspx
                 self::$randomFunc = 'randomCOM';
             } catch (Exception $e) {
             }
         }
     }
     return self::$randomFunc;
 }
开发者ID:johnedelatorre,项目名称:fusion,代码行数:19,代码来源:lib.uuid.php

示例2: initRandom

 public static function initRandom($how = NULL)
 {
     /* Look for a system-provided source of randomness, which is usually crytographically secure.
        /dev/urandom is tried first because tests suggest it is faster than other options. */
     if ($how === NULL) {
         if (self::$randomFunc != self::randChoose) {
             return self::$randomFunc;
         } else {
             if (is_readable('/dev/urandom')) {
                 $how = self::randDev;
             } else {
                 if (function_exists('openssl_random_pseudo_bytes')) {
                     $how = self::randOpenSSL;
                 } else {
                     if (function_exists('mcrypt_create_iv')) {
                         $how = self::randMcrypt;
                     } else {
                         $how = self::randCAPICOM;
                     }
                 }
             }
         }
         try {
             self::initRandom($how);
         } catch (Exception $e) {
             self::$randomFunc = self::randPoor;
         }
     } else {
         $source = NULL;
         switch ($how) {
             case self::randChoose:
                 self::$randomFunc = $how;
                 return self::initRandom();
             case self::randPoor:
                 self::$randomFunc = $how;
                 break;
             case self::randDev:
                 $source = @fopen('/dev/urandom', 'rb');
                 if (!$source) {
                     throw new UUIDException("Randomness source is not available.", 802);
                 }
                 break;
             case self::randOpenSSL:
                 if (!function_exists('openssl_random_pseudo_bytes')) {
                     throw new UUIDException("Randomness source is not available.", 802);
                 }
                 break;
             case self::randMcerypt:
                 if (!function_exists('mcrypt_create_iv')) {
                     throw new UUIDException("Randomness source is not available.", 802);
                 }
                 break;
             case self::randCAPICOM:
                 // See http://msdn.microsoft.com/en-us/library/aa388182(VS.85).aspx
                 if (!class_exists('COM', 0)) {
                     throw new UUIDException("Randomness source is not available.", 802);
                 }
                 try {
                     $source = new COM('CAPICOM.Utilities.1');
                 } catch (Exception $e) {
                     throw new UUIDException("Randomness source is not available.", 802, $e);
                 }
                 break;
             default:
                 throw new UUIDException("Randomness source not implemented.", 902);
         }
         self::$randomSource = $source;
         self::$randomFunc = $how;
     }
     return self::$randomFunc;
 }
开发者ID:Grandt,项目名称:DrUUID,代码行数:71,代码来源:lib.uuid.php


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