We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

gdonald on 09/27/06


Tagged

random pronouncable passwords


Versions (?)


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.