Forum : How can I create random passwords?
Brief description  about Online courses   join in Online courses
View prabeen  patra 's Profile

How can I create random passwords?

Hi,

Please anyone tell me how to create random passwords?
Asked by prabeen patra | Nov 23, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi prabeen

You can use the below code to create the random passwords

<?
function Random_Password($length) {
srand(date("s"));
$possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$string = "";
while(strlen($string)<$length) {
$string .= substr($possible_charactors, rand()%(strlen($possible_charactors))),1);
}
return($string);
}
echo Random_Password(8);
?>

Nov 23, 2009