module OpenSSL::Random
Public Class Methods
(String filename) → true
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 7693
def self.load_random_file: (String filename) -> true
Reads bytes from filename and adds them to the PRNG.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 7716
def self.random_add: (String str, Numeric entropy) -> self
Mixes the bytes from str into the Pseudo Random Number Generator(PRNG) state.
Thus, if the data from str are unpredictable to an adversary, this increases the uncertainty about the state and makes the PRNG output less predictable.
The entropy argument is (the lower bound of) an estimate of how much randomness is contained in str, measured in bytes.
Example
pid = $$ now = Time.now ary = [now.to_i, now.nsec, 1000, pid] OpenSSL::Random.add(ary.join, 0.0) OpenSSL::Random.seed(ary.join)
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 7730
def self.random_bytes: (Integer length) -> String
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 7738
def self.seed: (String seed) -> String
::seed is equivalent to ::add where entropy is length of str.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 7746
def self.status?: () -> bool
Return true if the PRNG has been seeded with enough data, false otherwise.
(String filename) → true
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 7756
def self.write_random_file: (String filename) -> true
Writes a number of random generated bytes (currently 1024) to filename which can be used to initialize the PRNG by calling ::load_random_file in a later session.