Dogecoin Core  1.14.2
P2P Digital Currency
random.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_RANDOM_H
7 #define BITCOIN_RANDOM_H
8 
9 #include "uint256.h"
10 
11 #include <stdint.h>
12 
13 /* Seed OpenSSL PRNG with additional entropy data */
14 void RandAddSeed();
15 
19 void GetRandBytes(unsigned char* buf, int num);
20 uint64_t GetRand(uint64_t nMax);
21 int GetRandInt(int nMax);
23 
28 void GetStrongRandBytes(unsigned char* buf, int num);
29 
36 public:
37  explicit FastRandomContext(bool fDeterministic=false);
38 
39  uint32_t rand32() {
40  Rz = 36969 * (Rz & 65535) + (Rz >> 16);
41  Rw = 18000 * (Rw & 65535) + (Rw >> 16);
42  return (Rw << 16) + Rz;
43  }
44 
45  uint32_t Rz;
46  uint32_t Rw;
47 };
48 
49 #endif // BITCOIN_RANDOM_H
Fast randomness source.
Definition: random.h:35
uint32_t rand32()
Definition: random.h:39
FastRandomContext(bool fDeterministic=false)
Definition: random.cpp:180
uint32_t Rw
Definition: random.h:46
uint32_t Rz
Definition: random.h:45
256-bit opaque blob.
Definition: uint256.h:123
int GetRandInt(int nMax)
Definition: random.cpp:168
uint64_t GetRand(uint64_t nMax)
Definition: random.cpp:153
void GetStrongRandBytes(unsigned char *buf, int num)
Function to gather random data from multiple sources, failing whenever any of those source fail to pr...
Definition: random.cpp:132
void RandAddSeed()
Definition: random.cpp:46
void GetRandBytes(unsigned char *buf, int num)
Functions to gather random data via the OpenSSL PRNG.
Definition: random.cpp:125
uint256 GetRandHash()
Definition: random.cpp:173