Module: RbNaCl::Random
- Extended by:
- Sodium
- Defined in:
- lib/rbnacl/random.rb
Overview
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.
Class Method Summary collapse
-
.random_bytes(n = 32) ⇒ String
Returns a string of random bytes.
Methods included from Sodium
primitive, sodium_constant, sodium_function, sodium_primitive, sodium_type
Class Method Details
.random_bytes(n = 32) ⇒ String
Returns a string of random bytes
22 23 24 25 26 |
# File 'lib/rbnacl/random.rb', line 22 def self.random_bytes(n=32) buf = RbNaCl::Util.zeros(n) @mutex.synchronize { c_random_bytes(buf, n) } buf end |