18 if(!
defined(
'PHP_WINDOWS_VERSION_BUILD') && extension_loaded(
'openssl'))
21 $rand = openssl_random_pseudo_bytes($length, $secure);
22 if(
false !== $rand && $secure ===
true)
28 if(extension_loaded(
'mcrypt'))
33 strtoupper(substr(PHP_OS, 0, 3)) !==
'WIN' ||
34 version_compare(PHP_VERSION,
'5.3.7') >= 0
37 $rand = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
38 if($rand !==
false && strlen($rand) === $length)
47 for($i = 0; $i < $length; $i++)
49 $rand .= chr(mt_rand(0, 255));
static getBytes($length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'