Types
SystemRandom = object bytesIt: iterator (self: var SystemRandom): uint8 {.closure.}
- Random number generator based on bytes provided by the operating system's cryptographic source (see urandom)
- Period: none
- State: none (but bytes are obtained in 128-byte chunks)
Procs
proc urandom(size: Natural): seq[uint8] {.raises: [OSError], tags: [ReadIOEffect].}
-
Returns a seq of random integers 0 <= n < 256 provided by the operating system's cryptographic source
POSIX: Reads and returns size bytes from the file /dev/urandom.
Windows: Returns size bytes obtained by calling CryptGenRandom. Initialization is done before the first call with CryptAcquireContext(..., PROV_RSA_FULL, CRYPT_VERIFYCONTEXT).
Raises OSError on failure.
Source proc urandom[](size: (static[Natural]){lit}): array[size, uint8]
- Returns an array of random integers 0 <= n < 256 provided by the operating system's cryptographic source. Source
proc randomUint8(self: var SystemRandom): uint8 {.inline, raises: [Exception], tags: [RootEffect].}
- Source
proc initSystemRandom(): SystemRandom {.raises: [], tags: [].}
- Initializes and returns a new SystemRandom Source