Random Number GeneratorThis is the best way to generate a secure completely random number.
Firstly, we need two 'not-so-secure' random numbers as seed numbers for our ultimate RNG algorithm.
In PHP, we can run "rand(10,10000)" twice, which outputs:
random_number: 9380, random_number_2: 9880
Now that we have our random numbers (as seeds), we can run them through the following algorithm:
$output = $random_number x tan(pi() / $random_number_2)
If we run our two random seed numbers through this algorithm the output is: 2.9826052716425
This is, by itself, a decent random number, but we can go deeper for more security.
If we take the output number after the decimal place, we can then have access to a secure random number within number space that has decent entropy and cannot be guessed.
If we use '$whole = floor($output);' we get: 2.
Then, we can find the fraction value using 'list($whole, $decimal) = explode(".", $output);'
After we have calculated the decimal value we arrive at our final secure random number: 9826052716425
Full Working PHP code
$random_number = rand(10,10000); $random_number_2 = rand(10, 10000); $output = $random_number * (tan(pi() / $random_number_2)); $whole = floor($output); list($whole, $final_secure_number) = explode('.', $output); echo $final_secure_number;
All Rights Reserved