mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-12 00:59:48 +01:00
parent
0ba1a04c05
commit
29b1bb7a58
@ -56,9 +56,10 @@ class Random
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
|
||||
try {
|
||||
return random_bytes($length);
|
||||
} catch (\Error $e) {
|
||||
// If a sufficient source of randomness is unavailable, random_bytes() will emit a warning.
|
||||
return \random_bytes($length);
|
||||
} catch (\Throwable $e) {
|
||||
// If a sufficient source of randomness is unavailable, random_bytes() will throw an
|
||||
// object that implements the Throwable interface (Exception, TypeError, Error).
|
||||
// We don't actually need to do anything here. The string() method should just continue
|
||||
// as normal. Note, however, that if we don't have a sufficient source of randomness for
|
||||
// random_bytes(), most of the other calls here will fail too, so we'll end up using
|
||||
|
Loading…
Reference in New Issue
Block a user