tangetools/goodpasswd/goodpasswd

37 lines
1.1 KiB
Plaintext
Raw Normal View History

2012-09-04 13:32:24 +00:00
#!/usr/bin/perl
# This program generates passwords that:
#
# * are hard to guess
# * will be displayed unambigously in any (normal) font
# * will survive being passed through a bad fax machine
# * will survive being passed through handwriting
2012-09-04 13:32:24 +00:00
# * has UPPER lower number and sign
#
# Too close: B8 cC g9 6G kK lI l1 oO O0 pP sS uU vV xX zZ Z2 ,. :; `' S5
2012-09-04 13:32:24 +00:00
# Causes problems in URLs: @/:
# Causes problems in shell: ! " # $ & ( ) [ ] { } ? | < > \ * =
2012-09-04 13:32:24 +00:00
# SQL uses: % for wildcard
# Hard to type: ^ ~ ¨ ¤ § ½ æ ø å Æ Ø Å
# Never 2 same chars next to eachother. (--) is bad
# Do not start with '-' or '+' as that looks like an (long) option
#
# US-kbd: ~!@#$%^&*()_+ [] {} ;'\ :"| < > ,./ <>?
# DK-kbd: §!"#¤%&/()=?` å" Å^ æø' ÆØ* < > ,.- ;:_
# Common: ! # % < > ,.
2012-09-04 13:32:24 +00:00
my $pw;
my @chars=split //, 'abdefhijmnqrtyADEFHJLMNQRTY347+-';
2012-09-04 13:32:24 +00:00
do {
$pw = "";
for (1..12) {
$pw .= $chars[rand $#chars+1]
2012-09-04 13:32:24 +00:00
}
} while (($pw =~ /^[+-]/ or $pw =~ /(.)\1/) or
not($pw =~ /[A-Z]/ and
2012-09-04 13:32:24 +00:00
$pw =~ /[a-z]/ and
$pw =~ /[0-9]/ and
$pw =~ /[^a-zA-Z0-9]/));
print "$pw\n";