Discussion board
How can I create random passwords?
By prabeen patra
Hi,

Please anyone tell me how to create random passwords?
Reply
Post   Reset
Teacher SiliconIndia replied to prabeen patra Monday, November 23, 2009
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);
?>