-
-
Save krhitoshi/915320 to your computer and use it in GitHub Desktop.
Password Generator written in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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