標籤:linux perl
#!/usr/bin/perlmy $characterset = ‘abcdefghijkmnopqrstuvwxyz23456789ABCDEFGHIJKLMNPQRSTUVWXYZ‘;#$characterset .= ‘[email protected]$%^()_{},./<>?-‘;#$characterset .= "[email protected]$%^&*()_+|{},./<>?-=\";#$characterset .= ‘[email protected]#$%^*()_|{},./<>?-=\‘;$characterset .= ‘@#%^*()_=-~,.?;:|‘;my $mininum = 8;my $maxinum = 10;sub MakePassword{my ($composition, $lowlength, $highlength) = @_;return ‘‘ unless $composition;my @p = split //, $composition;my $arraylength = @p;$lowlength = 7 if $lowlength < 1;$highlength =7 if $highlength < 1;if ($lowlength > $highlength) {($highlength, $lowlength) = ($lowlength, $highlength);}my $length = int(rand($highlength - $lowlength + 1));$length += $lowlength;my $password = ‘‘;for (1..$length) {my $i = int(rand($arraylength));$password .= $p[$i];}return $password;}my $password = MakePassword ($characterset, $mininum, $maxinum);print "$password\n";
--------------------------------------分割線--------------------------------------
知數堂 (http://zhishuedu.com)培訓是由資深MySQL專家葉金榮、吳炳錫聯合推出的專業優質培訓品牌,主要有MySQL DBA實戰最佳化和Python營運開發課程,是業內最有良心、最有品質的培訓課程。
本文出自 “老葉茶館” 部落格,請務必保留此出處http://imysql.blog.51cto.com/1540006/1879728
利用Perl產生隨機複雜密碼