Rails random pronouncable passwords


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.