note 19085 added to function.md5
| From: | dgolesny at avo-web dot de | Date: | Fri, 15 Feb 2002 10:49:52 +0000 |
| Subject: | note 19085 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26637@lists.php.net to get a copy of this message | ||
In reference to:cjgraham@tachegroup.com (14-Jan-2002 12:18)
If you use md5 to generate a password you only have 15 chars (0-9,a-f) and that is a really bad
password.
Better, if you work with 0-9,A-Z,a-z and generate it with e.g. this function:
function generatekey($count)
{
mt_srand((double)microtime()*1000000);
$key = "";
for ($i=0; $i<$count; $i++)
{
$c = mt_rand(0,2);
if ($c==0)
{
$key .= chr(mt_rand(65,90));
}
elseif ($c==1)
{
$key .= chr(mt_rand(97,122));
}
else
{
$key .= mt_rand(0,9);
}
}
return $key;
}
You can add other chars like *,&,%,$,§,-,., etc. of course, too, if needed.
Bye
Daniel
--
http://www.php.net/manual/en/function.md5.php
http://master.php.net/manage/user-notes.php?action=edit+19085
http://master.php.net/manage/user-notes.php?action=delete+19085
http://master.php.net/manage/user-notes.php?action=reject+19085