Sha256: 5d12bd118f0c62fe2de3cba9c168f112d192d5463612dbad013a6a72716b0c21
Contents?: true
Size: 733 Bytes
Versions: 6
Compression:
Stored size: 733 Bytes
Contents
# encoding: binary # frozen_string_literal: true module RbNaCl # Functions for random number generation # # This uses the underlying source of random number generation on the OS, so # /dev/urandom on UNIX-like systems, and the MS crypto providor on windows. module Random extend Sodium @mutex = Mutex.new sodium_function :c_random_bytes, :randombytes_buf, %i[pointer size_t] # Returns a string of random bytes # # @param [Integer] n number of random bytes desired # # @return [String] random bytes. def self.random_bytes(n = 32) buf = RbNaCl::Util.zeros(n) @mutex.synchronize { c_random_bytes(buf, n) } buf end end end
Version data entries
6 entries across 6 versions & 1 rubygems