this is a function i use to generate passwords, i would not want to have to write out all these lines everytime i needed it to execute instead its all in a function and i can just call the function which in turn calls allt those lines of code
Code: Select all
function generatepass($passlength = 8,$usecaps = 0) {//set to 1 for capital letters
$vals = array('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');
$vals1 = array('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','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');
$pass = '';
for($i = 0; $i < $passlength; $i++) {
if($usecaps == 0) {
shuffle($vals);
$pass .= $vals[mt_rand(0,35)];
}
if($usecaps == 1) {
shuffle($vals1);
$pass .= $vals1[mt_rand(0,61)];
}
}
return substr(md5($pass), 0, $passlength);
}