class Random

Defined at line 17 of file ../../third_party/cobalt/src/lib/crypto_util/random.h

An instance of Random provides some utility functions for retrieving

randomness.

Public Methods

void RandomBytes (byte * buf, std::size_t num)

Writes |num| bytes of random data from a uniform distribution to buf.

The caller must ensure that |buf| has enough space.

void RandomString (std::string * buf)

Writes |buf->size()| bytes of random data from a uniform distribution

into buf.

uint32_t RandomUint32 ()

Returns a uniformly random integer in the range [0, 2^32-1].

uint64_t RandomUint64 ()

Returns a uniformly random integer in the range [0, 2^64-1].

bool RandomBits (float p, byte * buffer, std::size_t size)

Writes 8 * |size| independent random bits to |buffer|. For each bit the

probability of being equal to one is the given p. p must be in the range

[0.0, 1.0] or the result is undefined. p will be rounded to the nearest

value of the form n/(2^32) where n is an integer in the range [0, 2^32].

|size| must be less than or equal to 256.

Returns false to indicate failure.

void ~Random ()

Defined at line 19 of file ../../third_party/cobalt/src/lib/crypto_util/random.h