mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-18 16:37:43 +03:00
Drop the use of OpenSSL as a fallback and use paragonie/random_compat
Fixes issue #80 for the 3.x series
This commit is contained in:
@@ -19,42 +19,6 @@ namespace Ramsey\Uuid\Generator;
|
||||
*/
|
||||
class RandomGeneratorFactory
|
||||
{
|
||||
/**
|
||||
* For testing, `openssl_random_pseudo_bytes()` override; if `true`, treat as
|
||||
* if `openssl_random_pseudo_bytes()` is not available
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $forceNoOpensslRandomPseudoBytes = false;
|
||||
|
||||
/**
|
||||
* For testing, `random_bytes()` override; if `true`, treat as if `random_bytes()`
|
||||
* is not available.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $forceNoRandomBytes = false;
|
||||
|
||||
/**
|
||||
* Returns `true` if the system has `openssl_random_pseudo_bytes()`
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function hasOpensslRandomPseudoBytes()
|
||||
{
|
||||
return (function_exists('openssl_random_pseudo_bytes') && !self::$forceNoOpensslRandomPseudoBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the system has `random_bytes()`
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function hasRandomBytes()
|
||||
{
|
||||
return (function_exists('random_bytes') && !self::$forceNoRandomBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a default random generator, based on the current environment
|
||||
*
|
||||
@@ -62,14 +26,6 @@ class RandomGeneratorFactory
|
||||
*/
|
||||
public static function getGenerator()
|
||||
{
|
||||
if (self::hasRandomBytes()) {
|
||||
return new RandomBytesGenerator();
|
||||
}
|
||||
|
||||
if (self::hasOpensslRandomPseudoBytes()) {
|
||||
return new OpenSslGenerator();
|
||||
}
|
||||
|
||||
return new MtRandGenerator();
|
||||
return new RandomBytesGenerator();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user