3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function random_entropy() { $ip = $_SERVER['REMOTE_ADDR']; $ip_multiplex = multiply_ip($ip); echo "IP Multiplex: $ip_multiplex | "; if(function_exists('openssl_random_pseudo_bytes')) { $i = time(); $i = ($i % 32); $bytes = openssl_random_pseudo_bytes($i, $cstrong); $hex = bin2hex($bytes); $openssl_num = hexdec($hex); $openssl_num = $openssl_num / $ip_multiplex; echo "openssl: $openssl_num | "; } if(function_exists('random_bytes')) { $i = time(); $i = ($i % 8); if($i == 0) { $i = 3; } $rand_num = random_bytes($i); $rand_num = bindec($rand_num); echo "Rand Num: $rand_num | "; } if(function_exists('mt_rand')) { $i = time(); $i_min = ($i % 4); $i_max = ($i % 8); $mt_rand_num = mt_rand($i_min, $i_max); $mt_rand_num = ($mt_rand_num + $i_max) / $i_min; echo "MT Rand Num: $mt_rand_num " . PHP_EOL; } return $ip_multiplex + $openssl_num + $rand_num + $mt_rand_num; } function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function multiply_ip($ip) { $ip_array = explode('.', $ip); $number = 1; foreach($ip_array as $node) { if($node == 0) { $node = microtime_float(); } $number = $number * $node; } return round($number); } echo random_entropy();
Output for 7.1.6
Notice: Undefined index: REMOTE_ADDR in /in/3rJ7A on line 5 IP Multiplex: 1499127503 | openssl: 7.7092544974516E+26 | Rand Num: 0 | MT Rand Num: 3.6666666666667 7.7092544974516E+26