module Bundler::SecureRandom

def alphanumeric(n = nil, chars: ALPHANUMERIC)

Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
def alphanumeric(n = nil, chars: ALPHANUMERIC)
  n = 16 if n.nil?
  choose(chars, n)
end if RUBY_VERSION < '3.3'

def bytes(n)

See Random.bytes

Returns a random binary string containing +size+ bytes.
def bytes(n)
  return gen_random(n)
end

def gen_random_openssl(n)

Implementation using OpenSSL
def gen_random_openssl(n)
  return OpenSSL::Random.random_bytes(n)
end

def gen_random_urandom(n)

Implementation using system random device
def gen_random_urandom(n)
  ret = Random.urandom(n)
  unless ret
    raise NotImplementedError, "No random device"
  end
  unless ret.length == n
    raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes"
  end
  ret
end