RE: [PHP-WIN] what's wrong with this while loop?
| From: | Murray @ PlanetThoughtful | Date: | Tue, 07 Jun 2005 07:21:17 +0000 |
| Subject: | RE: [PHP-WIN] what's wrong with this while loop? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-26074@lists.php.net to get a copy of this message | ||
> 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