4 Ağustos 2007 Cumartesi

Random password generator

# Unfriendly / easily mistaken characters (i o 0 1 l 0) are excluded.

def random_password(size = 8)
chars = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0)
(1..size).collect{|a| chars[rand(chars.size)] }.join
end

puts random_password.inspect


0 Comments: