diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index 55df0bde..a60857df 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -90,7 +90,7 @@ function crypt_random_string($length) { $fp = @fopen('/dev/urandom', 'rb'); } if ($fp !== true && $fp !== false) { // surprisingly faster than !is_bool() or is_resource() - return fread($urandom, $length); + return fread($fp, $length); } // method 3. pretty much does the same thing as method 2 per the following url: // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1391 @@ -240,4 +240,4 @@ function crypt_random_string($length) { $result.= $r; } return substr($result, 0, $length); -} \ No newline at end of file +}