Password Generators

Here is a collection of various simple password generating scripts that I have written in perl.

One Liners

perl -le 'print map{(a..z,A..Z,0..9)[rand 62]} 0..10'

XKCD style password generator

my(@pattern ) = qw(l l w w w w w w); 
my $wordsfile = "/usr/share/dict/words";
open(my $FH, $wordsfile);
my @words;
foreach(<$FH>) {
	push @words, $_ if m/^[a-z]{4,8}$/;
for(@pattern) {
   if(/^d$/) {
		print int rand(10);
	} elsif(/^l$/) {
		printf chr ord( 'a') + rand(26);
	} elsif(/^w$/) {
		print " " . $words[rand(@words)] . " ";
print "\n";

This reads in the words from a words file, selects the ones between 4 and 8 characters. The pattern is used to select tokens. The word token also adds a space at the beginning and end to seperate it from the other tokens.