Module: GmSSL::Random

Extended by:
FFI::Library
Defined in:
lib/gmssl/random.rb

Class Method Summary collapse

Class Method Details

.bytes(n = 256) ⇒ Object



13
14
15
16
17
# File 'lib/gmssl/random.rb', line 13

def self.bytes(n = 256)
  buf = FFI::MemoryPointer.new(:uint8, n)
  Random.rand_bytes(buf, n)
  buf.read_bytes(n).unpack('H*').first
end