mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 18:25:13 +00:00
- use openssl_random_pseudo_bytes if available (thanks wise.man!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@187 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
b1c7fed946
commit
e8d6d8d165
@ -63,6 +63,16 @@ function crypt_random($min = 0, $max = 0x7FFFFFFF)
|
|||||||
return $min;
|
return $min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (function_exists('openssl_random_pseudo_bytes')) {
|
||||||
|
// openssl_random_pseudo_bytes() is slow on windows per the following:
|
||||||
|
// http://stackoverflow.com/questions/1940168/openssl-random-pseudo-bytes-is-slow-php
|
||||||
|
if ((PHP_OS & "\xDF\xDF\xDF") != 'WIN') { // PHP_OS & "\xDF\xDF\xDF" == strtoupper(substr(PHP_OS, 0, 3)), but a lot faster
|
||||||
|
extract(unpack('Nrandom', openssl_random_pseudo_bytes(4)));
|
||||||
|
|
||||||
|
return abs($random) % ($max - $min) + $min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// see http://en.wikipedia.org/wiki//dev/random
|
// see http://en.wikipedia.org/wiki//dev/random
|
||||||
static $urandom = true;
|
static $urandom = true;
|
||||||
if ($urandom === true) {
|
if ($urandom === true) {
|
||||||
|
Loading…
Reference in New Issue
Block a user