Mnemonic Password Generator – a la Ruby

I wanted to have a mnenonic password generator for a little application that I’m writing in ruby, and couldn’t find one out there. So, I rolled my own. Actually, it’s a knock-off of a Python one I found, but that doesn’t really matter.

Do with this what you will. Hope it’s useful to someone.

def generateMnemonicPassword(letters=8, digits=4)
consonants = "bdfghklmnprstvwz"
vowels = "aeiou"
password = ""
(1 .. letters).each do |i|
range = i%2 == 1 ? consonants : vowels
password = password + range[rand(range.length), 1]
end
(1 .. digits).each do |i|
password = password + rand(10).to_s
end
password
end

It outputs fun and pronounceable passwords such as tepelopu8058, vonobuba6145 and kipowetu0270.

Enjoy!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon
  • Technorati
  • Pownce
  • Sphinn
  • Spurl
  • TailRank
  • LinkedIn
  • MySpace
blog comments powered by Disqus