# File lib/faker/internet.rb, line 48 def password(min_length = 8, max_length = 16, mix_case = true, special_chars = false) temp = Lorem.characters(min_length) diff_length = max_length - min_length if diff_length > 0 diff_rand = rand(diff_length + 1) temp += Lorem.characters(diff_rand) end if mix_case temp.chars.each_with_index do |char, index| temp[index] = char.upcase if index.even? end end if special_chars chars = %w(! @ # $ % ^ & *) Random.rand(min_length).times do |i| temp[i] = chars[Random.rand(chars.length)] end end temp end