module SecureRandom

def self.base36(n = 16)

def self.base36(n = 16)
  SecureRandom.alphanumeric(n, chars: BASE36_ALPHABET)
end

def self.base36(n = 16)

def self.base36(n = 16)
  SecureRandom.random_bytes(n).unpack("C*").map do |byte|
    idx = byte % 64
    idx = SecureRandom.random_number(36) if idx >= 36
    BASE36_ALPHABET[idx]
  end.join
end

def self.base58(n = 16)

def self.base58(n = 16)
  SecureRandom.alphanumeric(n, chars: BASE58_ALPHABET)
end

def self.base58(n = 16)

def self.base58(n = 16)
  SecureRandom.random_bytes(n).unpack("C*").map do |byte|
    idx = byte % 64
    idx = SecureRandom.random_number(58) if idx >= 58
    BASE58_ALPHABET[idx]
  end.join
end