note 28474 deleted from function.rand by aidan
| From: | aidan@php.net | Date: | Sat, 10 Jul 2004 02:34:23 +0000 |
| Subject: | note 28474 deleted from function.rand by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72966@lists.php.net to get a copy of this message | ||
Note Submitter: jnerin@svalero.es
----
Well, here is my way of making a password:
function generate_password ($length = 8, $valid_chars = "")
{
if($valid_chars=="")
{
$valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.";
}
$password="";
while($length>0)
{
$password.=$valid_chars[rand(0,strlen($valid_chars)-1)];
$length--;
}
return $password;
}
It's usefull, dead simple and flexible. And free ;-)