1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
|
<?
function randpass($len=8){
while(1){
switch(rand(1,5)){
case 1: $r = rand(65,90); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; //A-Z
case 2: $r = rand(48,57); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; //0-9
case 3: $r = rand(97,122); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break; //a-z
case 4: $r = rand(33,47); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break;
case 5: $r = rand(58,64); if(isset($set[$r])) continue; $pw.=chr($r); $set[$r] =1; break;
}
if(strlen($pw) == $len) break;
}
return $pw;
}
?>
|