Posted By

gdonald on 09/27/06


Tagged

random pronouncable passwords


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Rails random pronouncable passwords


 / Published in: Ruby
 

  1. # creates random pronouncable passwords
  2. def self.random_password
  3. c = %w( b c d f g h j k l m n p qu r s t v w x z ) +
  4. %w( ch cr fr nd ng nk nt ph pr rd sh sl sp st th tr )
  5. v = %w( a e i o u y )
  6. f, r = true, ''
  7. 6.times do
  8. r << ( f ? c[ rand * c.size ] : v[ rand * v.size ] )
  9. f = !f
  10. end
  11. 2.times do
  12. r << ( rand( 9 ) + 1 ).to_s
  13. end
  14. r
  15. end

Report this snippet  

You need to login to post a comment.