C/C++ API Reference
Loading...
Searching...
No Matches
pw::random::XorShiftStarRng64 Class Reference

Overview

A random generator based off the xorshift* algorithm.

The state is represented as an integer that, with each generation, performs exclusive OR (XOR) operations on different left/right bit shifts of itself. The * in xorshift* refers to a final multiplication that is applied to the output value. The final multiplication is essentially a nonlinear transformation that makes the algorithm stronger than a plain XOR shift.

Pigweed's implementation augments xorshift* with an ability to inject entropy to reseed the generator throughout its lifetime. When entropy is injected, the results of the generator are no longer completely deterministic based on the original seed.

See also Xorshift RNGs and An experimental exploration of Marsaglia's xorshift generators, scrambled.

Warning
This random generator is NOT cryptographically secure. It incorporates pseudo-random generation to extrapolate any true injected entropy. The distribution is not guaranteed to be uniform.
Inheritance diagram for pw::random::XorShiftStarRng64:
pw::random::RandomGenerator

Public Member Functions

 XorShiftStarRng64 (uint64_t initial_seed)
 
void Get (ByteSpan dest) final
 
void InjectEntropyBits (uint32_t data, uint_fast8_t num_bits) final
 
- Public Member Functions inherited from pw::random::RandomGenerator
template<class T >
void GetInt (T &dest)
 
template<class T >
void GetInt (T &dest, const T &exclusive_upper_bound)
 
virtual void Get (ByteSpan dest)=0
 
virtual void InjectEntropyBits (uint32_t data, uint_fast8_t num_bits)=0
 
void InjectEntropy (ConstByteSpan data)
 Injects entropy into the pool byte-by-byte.
 

The documentation for this class was generated from the following file: