Module: Xkcd936
- Defined in:
- lib/xkcd936.rb,
lib/xkcd936/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Class Method Summary collapse
-
.generate_passphrase(number = 5, dict = '/usr/share/dict/words') ⇒ String
Inspired by xkcd.com/936/ But I use 5 words as default instead of 4, since 5 words will achieve an entropy of: log(99171)/log(2)*5 = 82.988 This is enough.
Class Method Details
.generate_passphrase(number = 5, dict = '/usr/share/dict/words') ⇒ String
Inspired by xkcd.com/936/ But I use 5 words as default instead of 4, since 5 words will achieve an entropy of:
log(99171)/log(2)*5 = 82.988
This is enough. NIST recommends 80-bits for the most secure passwords. And it roughly needs 6 billions USD to break.
23 24 25 26 27 28 29 30 |
# File 'lib/xkcd936.rb', line 23 def generate_passphrase(number=5, dict='/usr/share/dict/words') pick_five = IO.readlines(dict).sample(number) passphrase = pick_five.map { |s| s.chomp.capitalize }.join # Let I18n skip validation and fall back to built in :en locale. # Otherwise you need to have a locale file. I18n.enforce_available_locales = false I18n.transliterate(passphrase) end |