std :: crypto::rng
Struct std::RngCtx
struct RngCtx {
unsigned int state[16];
unsigned char buf[RNG_BLOCK_SIZE];
unsigned long buf_pos;
}Fields
ChaCha20 key + nonce + counter
next byte to consume from buf
Methods
Initialise in place with automatic seeding (the OS's random source, else rdrand on x86-64, else /dev/urandom). Returns 1; aborts with a diagnostic if no entropy source is available (use init_seed() with your own entropy source on such targets).
Initialise in place with a user-provided 32-byte seed (deterministic; useful for tests).
Fill out[0..len-1] with cryptographically strong random bytes.
Return a random 32-bit unsigned integer.
Return a random 64-bit unsigned integer.
Return a uniform random integer in [0, bound).