麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Perl > 正文

使用Perl生成隨機密碼

2020-06-04 20:33:29
字體:
來源:轉載
供稿:網友

可以通過參數控制生成密碼中包括的字符種類

#!/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;            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 精品国产一区二区三区四区阿崩 | 久久精品视频一区二区三区 | 精品亚洲免费 | 国产精品.com| 久久99精品国产99久久6男男 | 免费观看黄色一级视频 | 亚洲免费永久 | 久草在线网址 | 精品国产一区二区三区久久久狼牙 | 精品国产一区二区在线观看 | 亚洲人成网站在e线播放 | 国产亚洲精品综合一区 | free japan xxxxhdsex69| tube69xxxxxhd| av电影在线观看网站 | 午夜精品小视频 | 国产二三区 | 最新av在线免费观看 | 综合国产在线 | 91色一区二区三区 | 色综合视频 | 久草在线资源福利站 | 中文字幕欧美日韩 | av懂色 | 99ri精品| 日本黄色一级电影 | 国产精品久久久免费 | 黄色a级片视频 | 羞羞网站 | 一级毛片真人免费播放视频 | 国产美女视频黄a视频免费 日韩黄色在线播放 | 亚洲精品av在线 | 欧美日韩在线播放 | 久久亚洲精品久久国产一区二区 | 黄色视频a级毛片 | a免费毛片| 欧美一区二区三区不卡免费观看 | 在线成人免费网站 | 自拍偷拍亚洲图片 | 精品久久一区二区三区 | 国产亚洲精品成人 |