The engines provided here should be initialized from an external source. For a thread-local cryptographically secure pseudo random number generator, use std.crypto.random. Be sure to use a CSPRNG when required, otherwise using a normal PRNG will be faster and use substantially less stack space.

TODO(tiehuis): Benchmark these against other reference implementations.

Namespaces

Functions

fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T

Convert a random integer 0 <= random_int <= maxValue(T), into an integer 0 <= r…

Convert a random integer 0 <= random_int <= maxValue(T), into an integer 0 <= result < less_than. This function introduces a minor bias.