module RbNaCl::Random
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.
Public Class Methods
random_bytes(n = 32)
click to toggle source
Returns a string of random bytes
@param [Integer] n number of random bytes desired
@return [String] random bytes.
# File lib/rbnacl/random.rb, line 25 def self.random_bytes(n = 32) buf = RbNaCl::Util.zeros(n) @mutex.synchronize { c_random_bytes(buf, n) } buf end