Posted by Chas under php
CodeNOT
хм, например так:
function passwordGen($pass_length){
$pass="";
for($i=0;$i<$pass_length;$i++){
if(rand(0,1)==1){
$pass.=chr(rand(97,122));
}else{
$pass.=chr(rand(48,57));
}
}
if(preg_match_all("/[0-9]{".$pass_length."}/",$pass,$matches)){
passwordGen($pass_length);
}
if(preg_match_all("/[a-z]{".$pass_length."}/",$pass,$matches)){
passwordGen($pass_length);
}
return $pass;
}
echo passwordGen(7);