Hello,
I've got two random number/statistics questions I'd like you to
review. My first question is not directly related to PHP, but will be
implemented in PHP, as explained in my second question, so let's go:
I want to generate 10000 strings of x characters, with one chance (or
less) on a million that you can guess them by just randomly typing
them. So I need to know what is the value of x.
I wrote the following equation :
36^x/10000 = 1000000
<=> 36^x = 10000 * 1000000
<=> 36^x = 1010
<=> x = ln(1010)/ln(36)
<=> x = 23.025850929940456840179914546844/3.5835189384561100016249547167614
<=> x = 6.4254860446923437997173954827712
So, a 7-characters string would be good enough.
So my first question is: is my reasoning OK? Knowing my math
abilities, I doubt it very much! ;)
The second question I have is related to PHP's rand() function. I've
read many times that rand() is not random enough, especially when
generating long lists of this kind. Would you use something that's
more powerful than rand(), are there stronger random functions, within
PEAR for instance, or anything?
Thanks,
JFLac