Skip to content

Commit 92d7fb6

Browse files
author
padams
committed
cherrypicking 1763
1 parent 98415be commit 92d7fb6

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

owa_coreAPI.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,10 +1398,32 @@ public static function random($min, $max) {
13981398
static $rnd_value;
13991399

14001400
if ( strlen($rnd_value) < 8 ) {
1401-
$seed = microtime();
1402-
$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
1403-
$rnd_value .= sha1($rnd_value);
1404-
$rnd_value .= sha1($rnd_value . $seed);
1401+
1402+
$notrandom = false;
1403+
1404+
if ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
1405+
1406+
$rnd_value = bin2hex(openssl_random_pseudo_bytes(32, $cstrong));
1407+
1408+
if ( ! $cstrong ) {
1409+
1410+
$notrandom = true;
1411+
}
1412+
1413+
} else {
1414+
1415+
$notrandom = true;
1416+
}
1417+
1418+
if ( $notrandom ) {
1419+
1420+
$seed = microtime();
1421+
$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
1422+
$rnd_value .= sha1($rnd_value);
1423+
$rnd_value .= sha1($rnd_value . $seed);
1424+
1425+
}
1426+
14051427
//$seed = md5($seed . $rnd_value);
14061428
}
14071429
// Take the first 8 digits for our value

0 commit comments

Comments
 (0)