6 #ifndef FABCOIN_RANDOM_H 7 #define FABCOIN_RANDOM_H 22 uint64_t
GetRand(uint64_t nMax);
62 rng.
Output(bytebuf,
sizeof(bytebuf));
82 uint64_t ret = ReadLE64(bytebuf + 64 - bytebuf_size);
91 }
else if (bits > 32) {
92 return rand64() >> (64 - bits);
95 uint64_t ret = bitbuf & (~(uint64_t)0 >> (64 - bits));
106 int bits = CountBits(range);
109 if (ret <= range)
return ret;
114 std::vector<unsigned char>
randbytes(
size_t len);
131 static const ssize_t NUM_OS_RANDOM_BYTES = 32;
146 #endif // FABCOIN_RANDOM_H void Output(unsigned char *output, size_t bytes)
uint64_t randbits(int bits)
Generate a random (bits)-bit integer.
uint64_t rand64()
Generate a random 64-bit integer.
FastRandomContext(bool fDeterministic=false)
unsigned char bytebuf[64]
uint64_t randrange(uint64_t range)
Generate a random integer in the range [0..range).
bool Random_SanityCheck()
Check that OS randomness is available and returning the requested number of bytes.
void RandAddSeedSleep()
Add a little bit of randomness to the output of GetStrongRangBytes.
A PRNG class for ChaCha20.
void GetStrongRandBytes(unsigned char *buf, int num)
Function to gather random data from multiple sources, failing whenever any of those source fail to pr...
void RandomInit()
Initialize the RNG.
uint256 rand256()
generate a random uint256.
uint32_t rand32()
Generate a random 32-bit integer.
uint64_t GetRand(uint64_t nMax)
bool randbool()
Generate a random boolean.
void GetOSRand(unsigned char *ent32)
Get 32 bytes of system entropy.
void GetRandBytes(unsigned char *buf, int num)
Functions to gather random data via the OpenSSL PRNG.
std::vector< unsigned char > randbytes(size_t len)
Generate random bytes.