Skip to content

Instantly share code, notes, and snippets.

@krhitoshi
Created April 12, 2011 10:56
Show Gist options
  • Save krhitoshi/915320 to your computer and use it in GitHub Desktop.
Save krhitoshi/915320 to your computer and use it in GitHub Desktop.
Password Generator written in Ruby
#!/usr/bin/env ruby
num = 12
num_times = 1
if ARGV[0]
num_times = ARGV[0].to_i
end
if ARGV[1]
num = ARGV[1].to_i
end
list = ('a'..'z').to_a + ('A'..'Z').to_a + ('1'..'9').to_a
list.delete_if{|s| ['l','o','I','O','1'].include? s }
num_times.times{
begin
pass = ''
num.times{
rand_num = rand(list.size)
pass += "#{list[rand_num]}"
}
end until pass =~ /\d/
puts pass
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment