diff options
author | Andrey Andreev <narf@devilix.net> | 2015-12-14 15:42:29 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2015-12-14 15:42:29 +0100 |
commit | 788fb4aa823179e7c4401f5384207d916697bb7e (patch) | |
tree | 551fd91834cc4f259d44d2355638552130ca2749 /system/core | |
parent | 97ecf2fcce8e3133e286e16de1b49612235a8dcf (diff) | |
parent | bc05b84995d5425d6bdc28c43174e70b720840ce (diff) |
Merge branch '3.0-stable' into develop
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Security.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/system/core/Security.php b/system/core/Security.php index 36dea4cf2..e79bf8aff 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -593,6 +593,22 @@ class CI_Security { return FALSE; } + if (function_exists('random_bytes')) + { + try + { + // The cast is required to avoid TypeError + return random_bytes((int) $length); + } + catch (Exception $e) + { + // If random_bytes() can't do the job, we can't either ... + // There's no point in using fallbacks. + log_message('error', $e->getMessage()); + return FALSE; + } + } + // Unfortunately, none of the following PRNGs is guaranteed to exist ... if (defined('MCRYPT_DEV_URANDOM') && ($output = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM)) !== FALSE) { |