module Stringent

Constants

TABLE

Public Class Methods

generate(entropy: 256, table: TABLE) click to toggle source
# File lib/stringent.rb, line 6
def self.generate(entropy: 256, table: TABLE)
  number = SecureRandom.random_number(2 ** entropy)
  length = (entropy / Math.log2(table.size)).ceil

  Array.new(length) {
    number, modulo = number.divmod(table.size)
    table[modulo]
  }.join
end