a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 編程 > Perl > 正文

Perl-生成隨機密碼的方法

2020-02-23 19:46:22
字體:
來源:轉載
供稿:網友

Perl是一種豐富的計算機編程語言,它可以廣泛使用到大型機到便攜式設備上,有需要的小伙伴可以跟隨武林技術頻道小編的步伐進入下文參考一下,希望對你學習有幫助!

#!/usr/bin/perluse strict;use warnings;use Getopt::Std;sub show_help {  print "Useage:/n";  print "newp -aAnsl/n";  print "-a/t/t the password contains lower case letters(a-z)/n";  print "-A/t/t the password contains upper case letters(A-Z)/n";  print "-n/t/t the password contains numerical character(0-9)/n";  print "-s/t/t the password contains special symbols/n";  print "-u/t/t the password contains only unique characters/n";  print "-l length/t set the password length(default: 6)/n";  exit 0;}sub show_version {  print "Version: 0.2.1 Changed the default option: -l 9 -Ana. 2016-4-15/n";  exit 0;}### main programuse vars qw($opt_a $opt_A $opt_h $opt_l $opt_n $opt_s $opt_u $opt_v);getopts('aAhl:nsuv');&show_version if $opt_v;&show_help if $opt_h;my $len = $opt_l || 9;  # default length 9my $opt_cnt = 0;my @rand_str = ();# store all the charactersmy @num = qw(0 1 2 3 4 5 6 7 8 9);my @ABC = qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);my @abc = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);# my @sym = qw(! " $ % & ' * + - . / : ; < = > ? @ [ / ] ^ _ ` { | } ~);my @sym = qw(! $ % & * + - . / : ; < = > ? @ [ ] ^ _ ` { | } ~); # no " ' /unshift (@sym, '(', ')', '#', ','); # to prevent perl's complains or warnings.my @all_sym = (@num, @ABC, @abc, @sym);my @ch_src = ();if ((!$opt_a) && (!$opt_A) && (!$opt_n) && (!$opt_s)) {  $opt_a++;  $opt_A++;  $opt_n++;}if ($opt_a) {  $opt_cnt++;  my $i = rand @abc;  unshift @rand_str, $abc[$i];  if ($opt_u) {    if ($i>=1) {      $abc[$i-1] = shift @abc;    } else {      shift @abc;    }  }  unshift (@ch_src, @abc);}if ($opt_A) {  $opt_cnt++;  my $i = rand @ABC;  unshift @rand_str, $ABC[$i];  if ($opt_u) {    if ($i>=1) {      $ABC[$i-1] = shift @ABC;    } else {      shift @ABC;    }  }  unshift (@ch_src, @ABC);}if ($opt_n) {  $opt_cnt++;  my $i = rand @num;  unshift @rand_str, $num[$i];  if ($opt_u) {    if ($i>=1) {      $num[$i-1] = shift @num;    } else {      shift @num;    }  }  unshift (@ch_src, @num);}if ($opt_s) {  $opt_cnt++;  my $i = rand @sym;  unshift @rand_str, $sym[$i];  if ($opt_u) {    if ($i>=1) {      $sym[$i-1] = shift @sym;    } else {      shift @sym;    }  }  unshift (@ch_src, @sym);}if ($len < $opt_cnt) {  print "The count of characters[$len] should not be smaller " .     "than count of character types[$opt_cnt]./n";  exit -1;}if ($opt_u && $len > (@ch_src + @rand_str)) {  print "The total number of characters[".(@ch_src + @rand_str).     "] which could be contained " .     "in password is smaller than the length[$len] of it./n";  exit -1;}foreach (1..$len-$opt_cnt) {  my $i = rand @ch_src;  unshift @rand_str, $ch_src[$i];  if ($opt_u) {    if ($i>=1) {      $ch_src[$i-1] = shift @ch_src;    } else {      shift @ch_src;    }  }}foreach (1..$len) {  my $i = rand @rand_str;  print $rand_str[$i];  if ($i>=1) {    $rand_str[$i-1] = shift @rand_str;  } else {    shift @rand_str;  }}print "/n";exit 0;

以上就是武林技術頻道小編給大家分享的Perl-生成隨機密碼的方法,希望對大家學習Perl能夠有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 日本在线播放 | 国产免费看黄 | www伊人| 欧美成人免费在线视频 | 久久精品欧美一区二区三区不卡 | 天堂一区二区三区 | 欧美日韩视频在线 | 日韩在线视频观看 | 欧美精品在线一区二区三区 | 外国一级a毛片 | 成人午夜视频在线观看 | 美女黄网站视频免费 | 久久精品一 | 中文字幕第一页久久 | 91爱啪啪 | 久草视频首页 | 免费网站黄 | 久久噜 | 亚洲精品久久久日韩美女极品合集下载 | 黄色av电影在线看 | 欧美成年网站 | 精品一区二区免费 | 欧美黑人巨大久久久精品一区 | 免费的黄色小视频 | 在线精品亚洲欧美日韩国产 | 国产精品久久久久久久久久久久 | 羞羞视频网站免费看 | 国产成人亚洲综合 | 狠狠综合久久av一区二区小说 | 亚洲aⅴ网站 | 亚洲中字幕 | 色综合一区二区三区 | 午夜精品一区二区三区在线观看 | 狠狠色噜噜狠狠色综合久 | www.av7788.com| 欧美日韩大片在线观看 | 精品福利在线视频 | www.9色| 国产噜噜噜噜噜久久久久久久久 | 午夜视频色 | 在线干|