Flowdock
method

random_add

Importance_1
v2_4_6 - Show latest stable - 0 notes - Class: Random
random_add(p1, p2) public

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)
Show source
Register or log in to add new notes.