random_password_generator
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| random_password_generator [2018/12/08 12:49] – created 0.0.0.0 | random_password_generator [2019/01/30 11:32] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Random_password_generator ====== | ||
| - | |||
| < | < | ||
| - | #!/ | + | - !/ |
| - | # ============================================================================== | + | |
| - | # Name : random_password.pl | + | |
| - | # Description | + | |
| - | # | + | |
| - | # Notes : none | + | |
| - | # | + | |
| - | # Modification History | + | |
| - | # ==================== | + | |
| - | # When Who | + | |
| - | # ========= ================= ================================================== | + | |
| - | # 16-APR-13 Stuart Barkley | + | |
| - | # ============================================================================== | + | |
| $DEBUG=0; | $DEBUG=0; | ||
| - | my $password='' | + | my $password=//; |
| my $RULES_PASSED=0; | my $RULES_PASSED=0; | ||
| sub debug { | sub debug { | ||
| - | my $msg = $_[0]; | + | my $msg = $_[[0]]; |
| $DEBUG && print $msg; | $DEBUG && print $msg; | ||
| } | } | ||
| Line 27: | Line 25: | ||
| - | # ------------------- | + | - |
| - | # Generate a password | + | |
| - | # ------------------- | + | |
| sub generate_password { | sub generate_password { | ||
| my ($pwlen) = @_; | my ($pwlen) = @_; | ||
| - | return `head / | + | return `head / |
| } | } | ||
| Line 46: | Line 44: | ||
| #1. Has to start and end with an alphabetic character | #1. Has to start and end with an alphabetic character | ||
| - | if ($password !~ m/ | + | if ($password !~ m/^[[A-z]].*[[A-z]]$/) { |
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| Line 53: | Line 52: | ||
| #2. Has to contain at least 2 upper case characters | #2. Has to contain at least 2 upper case characters | ||
| - | if ($password !~ m/ | + | if ($password !~ m/[[A-Z]].*[[A-Z]]/) { |
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| #3. Has to contain at least 2 lower case characters | #3. Has to contain at least 2 lower case characters | ||
| - | if ($password !~ m/ | + | if ($password !~ m/[[a-z]].*[[a-z]]/) { |
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| #4. Has to contain at least 2 digits | #4. Has to contain at least 2 digits | ||
| - | if ($password !~ m/\d.*\d/) { | + | if ($password !~ m/\\d.*\\d/) { |
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| Line 72: | Line 74: | ||
| #5. Has to contain between 10 and 12 characters | #5. Has to contain between 10 and 12 characters | ||
| if ($password !~ m/ | if ($password !~ m/ | ||
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| Line 81: | Line 84: | ||
| #6. Has to contain only printable characters | #6. Has to contain only printable characters | ||
| - | if ($password !~ m/[ -~]/) { | + | if ($password !~ m/[[ -~]]/) { |
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| #7. Cannot contain certain special characters | #7. Cannot contain certain special characters | ||
| - | if ($password =~ m|[\/ | + | if ($password =~ m|[[\\/\\&\\*\\$]]|) { |
| - | debug " | + | debug " |
| + | "; | ||
| next; | next; | ||
| } | } | ||
| Line 98: | Line 103: | ||
| print $password; | print $password; | ||
| </ | </ | ||
| + | |||
random_password_generator.1544273361.txt.gz · Last modified: 2018/12/08 12:49 by 0.0.0.0
