Created
September 23, 2010 14:56
-
-
Save a2ikm/593745 to your computer and use it in GitHub Desktop.
generate password
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 | |
# | |
#= Password Generator | |
# | |
# check strength with cracklib | |
# | |
#== Usage | |
# | |
# $ pwdgen | |
# $ pwdgen 10 | |
# | |
# | |
#== Requirement | |
# | |
# * ruby 1.8.7+ | |
# * cracklib | |
# | |
chars = (0..9).to_a + ("a".."z").to_a + ("A".."Z").to_a | |
length = (ARGV[0] || 8).to_i | |
5.times do | |
pwd = Array.new(length) { |i| chars.choice }.join | |
puts `echo '#{pwd}' | cracklib-check` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment