Skip to content

Instantly share code, notes, and snippets.

@dougalcorn
Created September 22, 2011 20:27
Show Gist options
  • Select an option

  • Save dougalcorn/1235937 to your computer and use it in GitHub Desktop.

Select an option

Save dougalcorn/1235937 to your computer and use it in GitHub Desktop.
Generate XKCD style passwords on OS X
#!/usr/bin/env ruby
number_of_words = ARGV[0].to_i
number_of_words ||= 4
dictionary = File.read('/usr/share/dict/web2a').split
words = []
until words.length == number_of_words do
word = dictionary[rand(dictionary.size)]
next unless word.size <= 6
words << word.strip
end
puts words.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment