72 template <
typename T1>
inline uint256 Hash(
const T1 pbegin,
const T1 pend) {
73 static const uint8_t pblank[1] = {};
76 .
Write(pbegin == pend ? pblank : (
const uint8_t *)&pbegin[0],
77 (pend - pbegin) *
sizeof(pbegin[0]))
83 template <
typename T1,
typename T2>
84 inline uint256 Hash(
const T1 p1begin,
const T1 p1end,
const T2 p2begin,
86 static const uint8_t pblank[1] = {};
89 .
Write(p1begin == p1end ? pblank : (
const uint8_t *)&p1begin[0],
90 (p1end - p1begin) *
sizeof(p1begin[0]))
91 .
Write(p2begin == p2end ? pblank : (
const uint8_t *)&p2begin[0],
92 (p2end - p2begin) *
sizeof(p2begin[0]))
98 template <
typename T1>
inline uint160 Hash160(
const T1 pbegin,
const T1 pend) {
99 static uint8_t pblank[1] = {};
102 .
Write(pbegin == pend ? pblank : (
const uint8_t *)&pbegin[0],
103 (pend - pbegin) *
sizeof(pbegin[0]))
110 return Hash160(vch.begin(), vch.end());
114 template <
unsigned int N>
129 : nType(nTypeIn), nVersion(nVersionIn) {}
134 void write(
const char *pch,
size_t size) {
135 ctx.
Write((
const uint8_t *)pch, size);
170 :
CHashWriter(source_->GetType(), source_->GetVersion()),
173 void read(
char *pch,
size_t nSize) {
174 source->read(pch, nSize);
175 this->write(pch, nSize);
181 size_t now = std::min<size_t>(nSize, 1024);
195 template <
typename T>
204 const std::vector<uint8_t> &vDataToHash);
207 const uint8_t data[32], uint8_t output[64]);
209 #endif // BITCOIN_HASH_H void write(const char *pch, size_t size)
CHashVerifier< Source > & operator>>(T &&obj)
CHash160 & Write(const uint8_t *data, size_t len)
void Finalize(uint8_t hash[OUTPUT_SIZE])
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
uint160 Hash160(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
void ignore(size_t nSize)
Reads data from an underlying stream, while hashing the read data.
void Serialize(Stream &s, char a)
CRIPEMD160 & Write(const uint8_t *data, size_t len)
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
void Finalize(uint8_t hash[OUTPUT_SIZE])
uint64_t GetCheapHash()
Returns the first 64 bits from the resulting hash.
void Finalize(uint8_t hash[OUTPUT_SIZE])
void BIP32Hash(const ChainCode &chainCode, uint32_t nChild, uint8_t header, const uint8_t data[32], uint8_t output[64])
static const size_t OUTPUT_SIZE
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
CHashWriter(int nTypeIn, int nVersionIn)
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
CHash256 & Write(const uint8_t *data, size_t len)
void Finalize(uint8_t hash[OUTPUT_SIZE])
static const int PROTOCOL_VERSION
network protocol versioning
uint32_t MurmurHash3(uint32_t nHashSeed, const std::vector< uint8_t > &vDataToHash)
CHashVerifier(Source *source_)
CSHA256 & Write(const uint8_t *data, size_t len)
static const size_t OUTPUT_SIZE
static const size_t OUTPUT_SIZE
CHashWriter & operator<<(const T &obj)
void Unserialize(Stream &s, char &a)
void read(char *pch, size_t nSize)
A writer stream (for serialization) that computes a 256-bit hash.
A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160).
A hasher class for SHA-256.
static uint64_t ReadLE64(const uint8_t *ptr)
A hasher class for RIPEMD-160.