Module: Sodium::Random
- Defined in:
- lib/sodium/random.rb
Class Method Summary collapse
Class Method Details
.bytes(size) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/sodium/random.rb', line 4 def self.bytes(size) Sodium::Buffer.empty(size) do |buffer| Sodium::FFI::Random.randombytes_buf( buffer.to_ptr, buffer.bytesize ) end end |
.integer(max = 2 ** 32 - 1) ⇒ Object
13 14 15 |
# File 'lib/sodium/random.rb', line 13 def self.integer(max = 2 ** 32 - 1) Sodium::FFI::Random.randombytes_uniform(max) end |