note 28612 added to function.md5
| From: | inio at ucolick dot org | Date: | Fri, 17 Jan 2003 23:15:56 +0000 |
| Subject: | note 28612 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42304@lists.php.net to get a copy of this message | ||
Here's a password generator that creates more robust passwords:
srand((double)microtime()*1000000);
$unique_str = md5(rand(0,9999999));
$unique_str = base64_encode(pack("h*", $unique_str));
// that packs the 128-bit hex value into a 16-character binary
// string, then expands it out to a 20-ish character base 64 string.
// this middle of this string has reasonably high-quality random
// characters including all of 0-9,a-z,A-Z, and /
// now to prevent someone misreading easily mistaken characters,
// and chop it down to a reasonable length:
$unique_str = substr(strtr($unique_str, "l/1ID0O", "Ab3Ef6H"),5,8);
--
http://www.php.net/manual/en/function.md5.php
http://master.php.net/manage/user-notes.php?action=edit+28612
http://master.php.net/manage/user-notes.php?action=delete+28612
http://master.php.net/manage/user-notes.php?action=reject+28612