Documentation ¶
Overview ¶
Package rng implements a deterministic random number generator using cryptographic functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomSeed ¶
func RandomSeed() string
RandomSeed returns a random 16-character string with 80 bits of entropy.
Types ¶
type RNG ¶
type RNG struct { // Count is the number of bytes RNG has been advanced by. // // This number is not read by any RNG calculations, and is provided // for debugging only. Count uint64 // Flags to maintain compatibility with bugs in previous versions of RNG. SeparateUpdateSeed []byte ReverseFloat bool MaxValueFencepost bool MaxValueShift bool // contains filtered or unexported fields }
RNG is a deterministic random number generator.
func (*RNG) CheapFloat ¶
CheapFloat returns a real number in [0, 1), advancing the random state by 1 byte.
func (*RNG) Clone ¶
Clone returns a full copy of this RNG.
Canges to one will not be reflected in the other.
func (*RNG) RangeFloat ¶
RangeFloat returns a real number in [min, max), advancing the random state by 4 bytes.
func (*RNG) RangeInt ¶
RangeInt returns an integer in [min, max), advancing the random state by a variable amount.
func (*RNG) RangeIntFloat ¶
RangeIntFloat returns an integer in [min, max), advancing the random state by a variable amount.
This function matches the behavior of RangeInt for integer min and max, and matches the behavior of JavaScript for non-integers.
Non-integer min causes the result to have min's fractional part.
A non-integer difference between min and max causes the last number to have a lower probability of occurring.