One of the common issues with modern fonts is that certain characters can be easily confused. These include the letters and numbers 0,O,o,1,l,i and has been the subject of an XKCD comic.
Here are two simple scripts to generate a random alpha-numeric password which avoids ambiguous characters.
First python:
#!/usr/bin/python #This program just generates a random password between 10 and 14 characters #long while avoiding ambiguous characters. Generated passwords are composed #of 10-30% numeric, 40-60% lowercase and the rest uppercase chars. import random, string, re length = 10 + random.randrange(4) password = [] limit_digits = int(round(length * random.randrange(10, 30)/100.0)) limit_lower = int(round(length * random.randrange(40, 60)/100.0)) limit_upper = length - limit_digits - limit_lower password.extend(random.sample(re.sub("[01]", "", string.digits), limit_digits)) password.extend(random.sample(re.sub("[l]", "", string.ascii_lowercase), limit_lower)) password.extend(random.sample(re.sub("[IO]", "", string.ascii_uppercase), limit_upper)) random.shuffle(password) print ''.join(password)
Next, Perl:
#!/usr/bin/perl #This program just generates a random password between 8 and 12 characters long #while avoiding ambiguous characters. # use strict; srand; my @chars = qw(A B C D E F G H J K L M N P Q R S T U V W X Y Z a b c d e f g h i j k m n p q r s t u v w x y z 2 3 4 5 6 7 8 9 ); my $a = rand(4); for (my $i = 0; $i <= 8 + $a; $i++) { print $chars[rand($#chars)]; } print "\n";