Created
July 14, 2012 06:09
-
-
Save sstelfox/3109645 to your computer and use it in GitHub Desktop.
Quick password generator
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 | |
ambiguous_characters = %w{ O 0 l I 1 |} | |
special_characters = %w{ ! @ # $ % ^ & * ( ) - _ + = [ ] | ; : " , < . > / ? ~ } | |
character_set = [('a'..'z'), ('A'..'Z'), (0..9), special_characters].map do |item| | |
item.to_a | |
end | |
character_set.flatten!.map(&:to_s) | |
ambiguous_characters.each do |ac| | |
character_set.delete(ac) | |
end | |
5.times do | |
password = "" | |
64.times do | |
password += character_set[rand(character_set.length)].to_s | |
end | |
puts password | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment