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:
Ben Ramsey
2016-03-15 11:42:38 -05:00
parent a5626e3e58
commit 35247faecf
5 changed files with 11 additions and 73 deletions
+1 -45
View File
@@ -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();
}
}