首页 > 代码库 > 利用Perl生成随机复杂密码
利用Perl生成随机复杂密码
#!/usr/bin/perl my $characterset = ‘abcdefghijkmnopqrstuvwxyz23456789ABCDEFGHIJKLMNPQRSTUVWXYZ‘; #$characterset .= ‘~!@$%^()_{},./<>?-‘; #$characterset .= "~!@$%^&*()_+|{},./<>?-=\"; #$characterset .= ‘~!@#$%^*()_|{},./<>?-=\‘; $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生成随机复杂密码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。