Created
August 20, 2021 13:58
-
-
Save Decstasy/c080765410f5fb4f6375d7792f12c18c to your computer and use it in GitHub Desktop.
This file contains 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 -W | |
# Dennis Ullrich | |
### Password settings: | |
# Output settings: | |
$x = 4; # Passwords per line | |
$y = 25; # Lines | |
# (quantity,(charset)) | |
@lower = (6,('a'..'x')); | |
@upper = (6,('A'..'X')); | |
@numbers = (5,(0..9)); | |
@special = (3,('!','$','.','-','+')); | |
### MAIN | |
use List::Util qw(shuffle); | |
use Getopt::Long; | |
GetOptions( | |
'single!' => \$single, | |
'no-newline!' => \$no_newline, | |
) or die "Incorrect usage!\n"; | |
if ($single){ | |
$no_newline ? print &pwgen : print &pwgen."\n"; | |
exit(0); | |
} | |
for (1..$y){ | |
my $line; | |
for (1..$x){ | |
$line .= &pwgen." "; | |
} | |
print $line."\n"; | |
} | |
sub random{ | |
my $chars = shift(@_); | |
my $string; | |
my $range = $#_ + 1; | |
for (1..$chars){ | |
$string .= $_[int(rand($range))]; | |
} | |
return $string; | |
} | |
sub pwgen{ | |
my $pw = &random(@lower); | |
$pw .= &random(@upper); | |
$pw .= &random(@special); | |
$pw .= &random(@numbers); | |
my @pw = split //, $pw; | |
return join '', shuffle(@pw[0..$#pw]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment