Random Password Progam Redux

written

Well this goes to show that I should always Google first, think later. The apg program seems to do everything I need and with much more flexibility.

First install apg

apt-get install apg

Then the ruby code becomes:

def random_passwd
  `apg -m 5 -x 5 -M LN -E oO0lL -n 1`
end

apg Options Used

Linux Manual for apg

  1. -m 5 – minimum length of 5 characters
  2. -X 5 – maximum length of 5 characters
  3. -M LN – mode L – must be all lowercase letters. Mode N – must use a number
  4. -E oO0lL – exclude lower case ‘oh’, upper case ‘oh’, zero, lower ‘el’, and upper ‘el’
  5. -n 1 – only generate 1 password.

Example output:

ruby -e '20.times{ puts `apg -m 5 -x 5 -M LN -E oO0lL -n 1` }'
ugof7
skyn1
6glel
zonn3
vawl4
worg7
2drov
jops3
9oshk
pram1
tork6
riad1
myaj9
reft6
on4ax
ojej5
rhim2
glok2
yeac1
wuev5

Points of interest

  1. It could take apg up to a second to generate a single password. This could be due subprocess startup, or the generator. I don’t know.
  2. The algorithm it uses creates pronounceable passwords. It’s unlikely for it to generate a real words.