Friday, October 2, 2009

Random Password Generator - PHP

function fnRandomPasswordGenerator($length = 6)
{
$pass = '';
$new = '';

// all the chars we want to use
$all = explode(" ",
"a b c d e f g h i j k l m n o p q r s t u v w x y z "
."A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
."0 1 2 3 4 5 6 7 8 9");

for($i=0; $i < $length; $i++)
{
srand((double)microtime()*1000000);
$pass .= $all[rand(0,61)];
$arr[] = $all[rand(0,61)];
$new .= $arr[$i];
}

return $new;
}



Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script

1 comment:

Unknown said...

I have tried this code to generate a random password. Mobile App Designing