If you do write this, please don't call it a password generator, else people might use these things for passwords. :-)
Excellent point. This is for creating one-time invitation codes for users to participate in surveys and not for actual passwords.
Thanks to a link posted by someone else, I was able to find a list of nearly 113,000 words between 4 and 12 characters long that can be used. Even though that's a lot of words, as Chris points out above, it would be trivial to write a script to try every combination of the words...
For those interested, here's the simple function to grab a number of words from a text file containing each word on it's own line:
define('WORDCODE_NUMWORDS',2); define('WORDCODE_SEPERATOR','-'); function _getWordCode() { $retval = ''; $chosenwords = array();
$file = 'words.txt'; $fp = fopen($file,'r'); $fsize = filesize($file);
for($x=0;$x<WORDCODE_NUMWORDS;$x++) { $pos = mt_rand(0,$fsize); fseek($fp,$pos); while(fgetc($fp) != "\n") { fseek($fp,--$pos); } $chosenwords[] = trim(fgets($fp)); }
return implode(WORDCODE_SEPERATOR,$chosenwords); }
Anyone thinking of suggesting file() and array_rand() should try it themselves before doing so. ;)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php