Created
September 5, 2015 14:27
-
-
Save xtetsuji/a2e887e55552676e37c8 to your computer and use it in GitHub Desktop.
Password checker for ntt-east at-billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# アットビリング用に設定できるパスワードのチェック | |
# OGATA Tetsuji at 2015/09/05 | |
# MITライセンスなのでご自由にどうぞ | |
use strict; | |
use warnings; | |
my $string = shift; | |
if ( length $string == 0 ) { | |
print "$0 PASSWORD_STRING\n"; | |
exit; | |
} | |
my $char_re = qr{[!"#$%&'()=;:,./+*_\?-]}; | |
my $invalid_char_re = qr{[^0-9a-zA-Z!"#$%&'()=;:,./+*_\?-]}; | |
local $@; | |
eval { | |
die "短すぎです" if length $string < 9; | |
die "長すぎです" if length $string > 32; | |
die "数字が入っていません" if $string !~ /[0-9]/; | |
die "英小文字が入っていません" if $string !~ /[a-z]/; | |
die "英大文字が入っていません" if $string !~ /[A-Z]/; | |
die "記号が入っていません" if $string !~ /$char_re/; | |
die "使えない記号が入っています" if $string =~ /$invalid_char_re/; | |
}; | |
if ( $@ ) { | |
my $err = $@; | |
$err =~ s/ at .*//; | |
print "$err\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment