Method: Password.random

Defined in:
lib/password.rb

.random(length = 8) ⇒ Object

Generate a random password of length characters. Unlike the Password.phonemic method, no attempt will be made to generate a memorable password. Generated passwords may contain any of the characters in Password::PASSWD_CHARS.



370
371
372
373
374
375
376
377
# File 'lib/password.rb', line 370

def Password.random(length=8)
  pw = ""
  nr_chars = PASSWD_CHARS.size

  length.times { pw << PASSWD_CHARS[ rand( nr_chars ) ] }

  Password.new( pw )
end