Module: PasswordGenerator
- Defined in:
- lib/password_generator.rb
Constant Summary collapse
- CHARACTER_SET =
"".tap do |string| string << ('a'..'z').to_a.inject(:+) string << ('A'..'Z').to_a.inject(:+) string << (0..9).to_a.inject(:+) string << '!@#$%^&*()_+=' end
Class Method Summary collapse
Class Method Details
.generate_password(length = 20) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/password_generator.rb', line 10 def self.generate_password(length = 20) string = '' length.times do |i| max_index = CHARACTER_SET.length index = rand(max_index) character = CHARACTER_SET[index] string << character end string end |