Skip to content

Instantly share code, notes, and snippets.

@a2ikm
Created September 23, 2010 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a2ikm/593745 to your computer and use it in GitHub Desktop.
Save a2ikm/593745 to your computer and use it in GitHub Desktop.
generate password
#!/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