Created
September 22, 2011 20:27
-
-
Save dougalcorn/1235937 to your computer and use it in GitHub Desktop.
Generate XKCD style passwords on OS X
This file contains hidden or 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 | |
| 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