Skip to main content

Module rand

Module rand 

Source
Expand description

The operating system’s random number generator.

fill and fill_uninit write bytes from the system’s cryptographically secure generator: unpredictable, and suitable for keys.

SystemSource
Linuxgetrandom
macOSgetentropy, 256 bytes at a time
WindowsProcessPrng (bcryptprimitives.dll)
WASIrandom_get

Each call reaches the system: nothing is buffered in the process. A program that wants many small random values should seed its own generator from one call.

Functions§

fill
Fills buf with random bytes.
fill_uninit
Fills buf with random bytes, and returns it as initialised.