Monday, March 24, 2014

PHP Code To Make A Random Password

This function can generate a random password, use alphanumeric character, and eliminating the ambiguous character. Here the code:
function randomPassword(){
$digit = 8;
$karakter = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";

srand((double)microtime()*1000000);
$i = 0;
$pass = "";
while ($i <= $digit-1)
{
$num = rand() % 32;
$tmp = substr($karakter,$num,1);
$pass = $pass.$tmp;
$i++;
}
return $pass;
}

$password = randomPassword()
echo $password;
Good Luck !!!

0 comments:

Post a Comment