Password generator
This commit is contained in:
parent
652079119e
commit
1cb97260ba
3 changed files with 42 additions and 0 deletions
1
README
1
README
|
@ -3,4 +3,5 @@ This repo contains various scripts which I figure could be useful to someone.
|
||||||
backup/ A set of backup scripts
|
backup/ A set of backup scripts
|
||||||
ban-ssh-morons/ A "SSH bruteforce attempts to iptables blacklist" daemon
|
ban-ssh-morons/ A "SSH bruteforce attempts to iptables blacklist" daemon
|
||||||
|
|
||||||
|
See README.OtherScripts for scripts too small to deserve their own directory.
|
||||||
License: WTFPL (http://sam.zoy.org/wtfpl/)
|
License: WTFPL (http://sam.zoy.org/wtfpl/)
|
||||||
|
|
9
README.OtherScripts
Normal file
9
README.OtherScripts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
make-password.pl
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Generates a random password. Usage:
|
||||||
|
|
||||||
|
perl make-password.pl [simple] [<length>]
|
||||||
|
|
||||||
|
"simple" indicates that the password should consist of alphanumeric characters
|
||||||
|
only. If no length is specified, the default is 13.
|
32
make-password.pl
Executable file
32
make-password.pl
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
sub genPassword
|
||||||
|
{
|
||||||
|
my $len = shift;
|
||||||
|
my $simple = shift;
|
||||||
|
my @characters;
|
||||||
|
@characters = ( 'A' .. 'Z' , 'a' .. 'z' , '0' .. '9' );
|
||||||
|
unless ( $simple ) {
|
||||||
|
@characters = ( @characters ,
|
||||||
|
'!' , '=' , '+' , '-' , '/' , '*' , '.' ,
|
||||||
|
'(' , ')' , '[' , ']' , '{' , '}' );
|
||||||
|
}
|
||||||
|
while ( @characters < $len * 2 ) {
|
||||||
|
@characters = ( @characters , @characters );
|
||||||
|
}
|
||||||
|
for ( my $i = 0 ; $i < 10 ; $i ++ ) {
|
||||||
|
@characters = sort { int( rand() * 3 ) - 1 } @characters;
|
||||||
|
}
|
||||||
|
return join( '' , @characters[ 0 .. ( $len - 1 ) ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
my $mlen = 13;
|
||||||
|
my $simple = 0;
|
||||||
|
if ( $ARGV[0] eq 'simple' ) {
|
||||||
|
shift @ARGV;
|
||||||
|
$simple = 1;
|
||||||
|
}
|
||||||
|
$mlen = int( $ARGV[0] ) if $ARGV[0];
|
||||||
|
print genPassword( $mlen , $simple ) . "\n";
|
Loading…
Reference in a new issue