diff options
Diffstat (limited to 'src/hash.h')
-rw-r--r-- | src/hash.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/hash.h b/src/hash.h index 39d42eefe2..f2a0ebfe1f 100644 --- a/src/hash.h +++ b/src/hash.h @@ -19,10 +19,12 @@ class CHash256 { private: CSHA256 sha; public: - void Finalize(unsigned char *hash) { - unsigned char buf[32]; + static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE; + + void Finalize(unsigned char hash[OUTPUT_SIZE]) { + unsigned char buf[sha.OUTPUT_SIZE]; sha.Finalize(buf); - sha.Reset().Write(buf, 32).Finalize(hash); + sha.Reset().Write(buf, sha.OUTPUT_SIZE).Finalize(hash); } CHash256& Write(const unsigned char *data, size_t len) { @@ -41,10 +43,12 @@ class CHash160 { private: CSHA256 sha; public: - void Finalize(unsigned char *hash) { - unsigned char buf[32]; + static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE; + + void Finalize(unsigned char hash[OUTPUT_SIZE]) { + unsigned char buf[sha.OUTPUT_SIZE]; sha.Finalize(buf); - CRIPEMD160().Write(buf, 32).Finalize(hash); + CRIPEMD160().Write(buf, sha.OUTPUT_SIZE).Finalize(hash); } CHash160& Write(const unsigned char *data, size_t len) { |