create random password

by Guna 2012-07-23 18:50:59

While we creating random password we often use time() function with md5() to get unique
hashes. What happens if the functions processed exact time?. Below i've listed a function
which creates random unique password hashes.

This function will use mt_rand to get random number along with the tocken then it is passed
in md5() to create unique password hashes.


//$l= lenth of the created password
function unique_id($l=3) {
$token="]#S$.";
$token.=uniqid(mt_rand(), true);
return substr(md5($token), 0, $l);
}

echo unique_id(7);


Tagged in:

855
like
0
dislike
0
mail
flag

You must LOGIN to add comments