Skip to content

Instantly share code, notes, and snippets.

@ivyl
Created April 8, 2012 01:00
Show Gist options
  • Save ivyl/2333321 to your computer and use it in GitHub Desktop.
Save ivyl/2333321 to your computer and use it in GitHub Desktop.
easy to remember password generator
#!/usr/bin/env ruby
# Usage: __FILE__ number_of_passwords words_in_password
#
# https://xkcd.com/936/
# This method is great, but people tend to chose only
# certain subset of words. This is solution.
#
# Generate set of X passwords and choose one.
#
# To dump dictionary (change pl to preferred language):
# aspell -l pl dump master | sed 's/\/.*//g' > dict
path = File.join(File.dirname(__FILE__), "dict")
dict = File.read(path).split
size = dict.size
ARGV[0].to_i.times do
pass = []
ARGV[1].to_i.times { pass << dict[rand(size)] }
puts pass.join " "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment