- changed $fp to $urandom (thanks, Ben!)

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@144 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2011-02-08 05:16:11 +00:00
parent a4d39a9e66
commit 27700e9ca7

View File

@ -68,7 +68,7 @@ function crypt_random($min = 0, $max = 0x7FFFFFFF)
$urandom = @fopen('/dev/urandom', 'rb'); $urandom = @fopen('/dev/urandom', 'rb');
} }
if (!is_bool($urandom)) { if (!is_bool($urandom)) {
extract(unpack('Nrandom', fread($fp, 4))); extract(unpack('Nrandom', fread($urandom, 4)));
// say $min = 0 and $max = 3. if we didn't do abs() then we could have stuff like this: // say $min = 0 and $max = 3. if we didn't do abs() then we could have stuff like this:
// -4 % 3 + 0 = -1, even though -1 < $min // -4 % 3 + 0 = -1, even though -1 < $min