Are PHP random numbers predictable? if so, how difficult would it be to predict random numbers that are in a range of 1 to 32? and is there any way to make it unpredictable?
<?php
function rand_best($min, $max) {
$generated = array();
for ($i = 0; $i < 100; $i++) {
$generated[] = mt_rand($min, $max);
}
shuffle($generated);
$position = mt_rand(0, 99);
return $generated[$position];
}
?>
mt_rand(), you should read up on the Mersenne Twister algorithm if you want to know how it works.mt_rand()provides better quality thanrand()(which is notably flawed). BTW, not random, not uniform and predictable are pretty different concepts: you just can't predict the next number if you don't know the seed.