4 ms·
I'm not sure how big your word-list is, but my (wbritish) is: $ wc -l /usr/share/dict/words 99156 /usr/share/dict/words Sticking with Ruby: > Math.log(
by e12e 9y ago
I'm not sure how big your word-list is, but my (wbritish) is:
$ wc -l /usr/share/dict/words
99156 /usr/share/dict/words
Sticking with Ruby:
> Math.log(99156,2)*3
=> 49.79223735944021
That's some ways off from 54-bits, but you can bump it over 66 bits by using four words.
Second, from what I gather from [1],[2] and [3] - you should probably use SecureRandom for cryptographic/security purposes:
$ ruby -e 'require "securerandom"; puts \
File.read("/usr/share/dict/words").lines.sample(4, \
random:SecureRandom).map(&:chomp).join(" ")'
remorse's mountaineers said arrival's
[1] https://ruby-doc.org/core-2.4.1/Array.html#method-i-sample https://ruby-doc.org/core-2.4.1/Array.html#method-i-sample
[2] https://ruby-doc.org/core-2.4.1/Random.html https://ruby-doc.org/core-2.4.1/Random.html
[3] https://ruby-doc.org/stdlib-2.4.1/libdoc/securerandom/rdoc/SecureRandom.html https://ruby-doc.org/stdlib-2.4.1/libdoc/securerandom/rdoc/S...