From 54a51c3471662ecde8e3579eb63090a87a0525cb Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 5 Feb 2015 18:52:03 -0500 Subject: [PATCH] Define fc::ripemd160::hash() for arbitrary serializable objects --- include/fc/crypto/ripemd160.hpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/include/fc/crypto/ripemd160.hpp b/include/fc/crypto/ripemd160.hpp index 4c2e3b6..2539412 100644 --- a/include/fc/crypto/ripemd160.hpp +++ b/include/fc/crypto/ripemd160.hpp @@ -1,14 +1,15 @@ #pragma once -#include -#include -#include +#include +#include +#include +#include namespace fc{ class sha512; class sha256; -class ripemd160 +class ripemd160 { public: ripemd160(); @@ -25,14 +26,14 @@ class ripemd160 static ripemd160 hash( const string& ); template - static ripemd160 hash( const T& t ) - { - ripemd160::encoder e; - e << t; - return e.result(); - } + static ripemd160 hash( const T& t ) + { + ripemd160::encoder e; + fc::raw::pack( e, t ); + return e.result(); + } - class encoder + class encoder { public: encoder(); @@ -64,10 +65,10 @@ class ripemd160 friend bool operator != ( const ripemd160& h1, const ripemd160& h2 ); friend ripemd160 operator ^ ( const ripemd160& h1, const ripemd160& h2 ); friend bool operator >= ( const ripemd160& h1, const ripemd160& h2 ); - friend bool operator > ( const ripemd160& h1, const ripemd160& h2 ); - friend bool operator < ( const ripemd160& h1, const ripemd160& h2 ); - - uint32_t _hash[5]; + friend bool operator > ( const ripemd160& h1, const ripemd160& h2 ); + friend bool operator < ( const ripemd160& h1, const ripemd160& h2 ); + + uint32_t _hash[5]; }; class variant;