A Random Number Generator is the heart of most modern cryptosystems and has many uses such as generating encryption/decryption keys and randomly shuffling indexed values.

The RNG in CypherPoker uses a couple of different sources of cryptographically secure entropy or randomness.

The primary source of entropy is the generateRandomBytes function which uses the operating system's cryptographically secure random number generator.

The second source of entropy is a timer measuring the delta between expected and actual execution timings that serves as the input to a SHA256 hash function.

Both sources are combined via an XOR operation and fill a random byte buffer, or pool, which is refreshed at a random interval. When the pool is exhausted the primary entropy source is used.

The RNG class is instantiated with a desired buffer size and a random refresh interval range. Three public functions are provided for retrieving cryptographically secure random native numbers: getRandomReal, getRandomUint, and getRandomInt. To increase performance the stream buffer may be paused by calling pauseStreamBuffer when not needed and resumeStreamBuffer to resume again.