RE: what's wrong with this while loop?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Following my code is to write a 15digit random generated password into a
> file named test.txt. I was trying to keep it random generating 100
> passwords
> and be written into test.txt by using a while loop, however, the result is
> strange.
> 
> Take a look at the code (most of it is from php.net) and what's wrong with
> this while loop?
> besides, if I generate a large sum of passwords,say 50 million, will it be
> repetitive?
> Thank you!

Hi,

Don't have time at the moment to test out your code (hopefully someone else
will), but you may want to have a look at the str_shuffle() function, since
all you're doing is randomizing a known string.

Something like:

$key_chars =
str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
);

$random_password = substr($key_chars, 0, 15);

...should do the trick.

Can't comment on the randomization performed by str_shuffle, though, and do
you honestly need 50 million predetermined passwords?

Regards,

Murray

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux