本文整理匯總了PHP中UUID::randomFunc方法的典型用法代碼示例。如果您正苦於以下問題:PHP UUID::randomFunc方法的具體用法?PHP UUID::randomFunc怎麽用?PHP UUID::randomFunc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UUID
的用法示例。
在下文中一共展示了UUID::randomFunc方法的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;
}
示例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;
}