random pronounceable password generator

marcus • May 26th, 2007

a quick & simple random pronounceable password generator for ruby.

def random_pronouncable_password(size = 6)
  consonants = %w(b c d f g h j k l m n p qu r s t v w x z ch cr fr nd ng nk nt ph pr rd sh sl sp
st th tr 0 1 2 3 4 5 6 7 8 9 0)
  vocals = %w(a e i o u y)
  
  alternate=true
  password=''
  
  (size * 2).times do
    # get a random vocal or consonant
    chunk = (alternate ? consonants[rand * consonants.size] : vocals[rand * vocals.size])
    alternate = !alternate
    # randomly swap its case & add to password
    chunk = chunk.swapcase if rand > 0.5
    password << chunk
  end
  
  password
end

Tags

+opensource +ruby +snippets

1 Response to random pronounceable password generator

  1. steve
    xactly what i was looking for - thanks!

Reply

3d 4-space abstract aesthetic system aesthetics algorithm alien ambient ambisonics animation architecture art artificial audio audio research black&white book caskets classic clicks & cuts code color computer-vision conceptual art consoles cpp culture ddr design devices digtial fabrication documenta documentation drawing dynamics electricity electromagnetism electronics environment event exhibition experimental exploration fashion festival film flocking folk food fractal furniture gamedev generative genetic geometry glitch graphic hacks haptics hardware history hyperspace ideas illustration images inspiration installation instrument intelligence interactive interieur japan java knowledge management landscape library life light liquid live london math micro minimal modernism monochrome motion motion graphics multiples music naming nature nervous ink networked networking opensource osx painting paper particles performance personal photography physics playful politics press print processing processing.org programming quotes recipes research retro romance ruby scripts sculpture SENDUNG.net shopping snippets social software sound space space exploration craft space exploration craft orbiter supercollider swiss systems technology theory theremin toys transformed travel tricks typography universe video visual vj water web2.0 xcode