获取随机的由大小写字母和数字组成的八位密码

发表于:2007-07-04来源:作者:点击数: 标签:
show.pl #!/usr/bin/perl print Content-type: text/html\n\n; print html\n; print headmeta http-equiv=Content-Type content=text/html;charset=gb2312\n; print head\nbody bgcolor=#c0c0c0\n; print p /p; print p align=centerfont color=#8080FFbigst
show.pl

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head><meta http-equiv=Content-Type content=text/html;charset=gb2312>\n";
print "<head>\n<body bgcolor=#c0c0c0>\n";
print "<p> </p>";
print "<p align=center><font color=#8080FF><big><strong>送您一百个随机密码, 虽然不好记, 但是都是随机产生的, 很安全!</strong></big></font></p>\n";
print "<div align=center><center>";
print "<table border=1 bgcolor=#C0C0C0 cellspacing=1 cellpadding=3>\n";
for($i=0;$i<10;$i++)
{
print "<tr>";
for($j=0;$j<10;$j++)
{
print "<td>";
print &getstring;
print "</td>";
}
print "</tr>\n";
}
print "</table></center></div>\n";
print "<p></p>";

print "<p><center><a href=show.pl><span style=\"FONT-FAMILY: 宋体; FONT-SIZE: 10pt\">再算一遍</span></a></center></p>";
print "\n</body></html>\n";
exit;

sub getstring
{
$str="";
for($k=0;$k<8;$k++)
{
$num=int(rand(3));
if($num==0) { $str.=pack("c",rand(10)+48); }
elsif($num==1) { $str.=pack("c",rand(26)+65); }
elsif($num==2) { $str.=pack("c",rand(26)+97); }
}
return $str;
}

原文转自:http://www.ltesting.net