56        if (version_compare(PHP_VERSION, 
'7.0.0', 
'>=')) {
 
   58                return \random_bytes($length);
 
   59            } 
catch (\Throwable $e) {
 
   69        if (strtoupper(substr(PHP_OS, 0, 3)) === 
'WIN') {
 
   72            if (extension_loaded(
'mcrypt') && function_exists(
'class_alias')) {
 
   73                return mcrypt_create_iv($length);
 
   88            if (extension_loaded(
'openssl') && version_compare(PHP_VERSION, 
'5.3.4', 
'>=')) {
 
   89                return openssl_random_pseudo_bytes($length);
 
   93            if (extension_loaded(
'openssl')) {
 
   94                return openssl_random_pseudo_bytes($length);
 
  101                $fp = @fopen(
'/dev/urandom', 
'rb');
 
  103            if ($fp !== 
true && $fp !== 
false) { 
 
  104                return fread($fp, $length);
 
  111            if (extension_loaded(
'mcrypt')) {
 
  112                return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
 
  134        static $crypto = 
false, $v;
 
  135        if ($crypto === 
false) {
 
  137            $old_session_id = session_id();
 
  138            $old_use_cookies = ini_get(
'session.use_cookies');
 
  139            $old_session_cache_limiter = session_cache_limiter();
 
  141            if ($old_session_id != 
'') {
 
  142                session_write_close();
 
  146            ini_set(
'session.use_cookies', 0);
 
  147            session_cache_limiter(
'');
 
  150            $v = $seed = 
$_SESSION[
'seed'] = pack(
'H*', sha1(
 
  157                serialize($_OLD_SESSION)
 
  164            session_write_close();
 
  167            if ($old_session_id != 
'') {
 
  168                session_id($old_session_id);
 
  170                ini_set(
'session.use_cookies', $old_use_cookies);
 
  171                session_cache_limiter($old_session_cache_limiter);
 
  173                if ($_OLD_SESSION !== 
false) {
 
  175                    unset($_OLD_SESSION);
 
  189            $key = pack(
'H*', sha1($seed . 
'A'));
 
  190            $iv = pack(
'H*', sha1($seed . 
'C'));
 
  196                case class_exists(
'\phpseclib\Crypt\AES'):
 
  199                case class_exists(
'\phpseclib\Crypt\Twofish'):
 
  202                case class_exists(
'\phpseclib\Crypt\Blowfish'):
 
  205                case class_exists(
'\phpseclib\Crypt\TripleDES'):
 
  208                case class_exists(
'\phpseclib\Crypt\DES'):
 
  211                case class_exists(
'\phpseclib\Crypt\RC4'):
 
  215                    user_error(__CLASS__ . 
' requires at least one symmetric cipher be loaded');
 
  219            $crypto->setKey(
$key);
 
  221            $crypto->enableContinuousBuffer();
 
  235        while (strlen(
$result) < $length) {
 
  236            $i = $crypto->encrypt(microtime()); 
 
  237            $r = $crypto->encrypt(
$i ^ $v); 
 
  238            $v = $crypto->encrypt(
$r ^ 
$i); 
 
  241        return substr(
$result, 0, $length);
 
An exception for terminatinating execution or to throw for unit testing.
const MODE_CTR
#+ @access public
static string($length)
Generate a random string.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Pure-PHP implementation of AES.
Pure-PHP implementation of Blowfish.
Pure-PHP implementation of DES.
Pure-PHP implementation of RC4.
Pure-PHP Random Number Generator.
Pure-PHP implementation of Triple DES.
Pure-PHP implementation of Twofish.
Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic...
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']