note 28446 deleted from function.rand by irchtml
| From: | irchtml@php.net | Date: | Thu, 08 Apr 2004 14:56:43 +0000 |
| Subject: | note 28446 deleted from function.rand by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67823@lists.php.net to get a copy of this message | ||
Note Submitter: ogresamanosuke@hotmail.com
----
In addition to the above password code, you could also use 'gettimeofday' to get a random
string, MD5 it, and substr it down to your desired value. The problem of this, of course, is it can
be deciphered if the time of day the pass was made is figured out. (IE: if a hacker knew it was
between 5:10am and 5:15am on X day, he could shorten his checking area)
The nice advantage of the method you posted is that you not only control what content, but it
actually takes less time to do it in that fashion. The one thing I can suggest to anyone taking the
example though, is to replace this line:
$password .= substr($passwordChars,$randomNumber-1,1)
with this line:
$password.=$passwordChars{$randomNumber};
to speed things up a little. (Microseconds, but still.)