Posts Tagged script
Generate Random Password with php
Generate a random password is very common issue. lots of people do it in different way. well, we can do it very quickly. its very simple easy two line code for generate random password.
function gen_md5_password($len = 6) {
// function calculates 32-digit hexadecimal md5 hash
// of some random data
return substr(md5(rand().rand()), 0, $len);
}
From your main function we have to just call this function like:
$random_pass = gen_md5_password();
echo $random_pass;
this will show different random number. $len variables value can be change. if we are willing to make a random number of 12 digit. we have to set $len=12.
like: function gen_md5_password($len = 12)
Add comment December 13, 2008