diff --git a/include/fc/crypto/ripemd160.hpp b/include/fc/crypto/ripemd160.hpp index 4c2e3b6..2febd58 100644 --- a/include/fc/crypto/ripemd160.hpp +++ b/include/fc/crypto/ripemd160.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace fc{ @@ -28,7 +29,7 @@ class ripemd160 static ripemd160 hash( const T& t ) { ripemd160::encoder e; - e << t; + fc::raw::pack(e,t); return e.result(); } diff --git a/include/fc/crypto/sha256.hpp b/include/fc/crypto/sha256.hpp index 9a06bd7..4d2d606 100644 --- a/include/fc/crypto/sha256.hpp +++ b/include/fc/crypto/sha256.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace fc { @@ -25,7 +26,7 @@ class sha256 static sha256 hash( const T& t ) { sha256::encoder e; - e << t; + fc::raw::pack(e,t); return e.result(); } diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 8aa5558..7e58330 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -486,6 +486,15 @@ namespace fc { return tmp; } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } + template + inline void unpack( const std::vector& s, T& tmp ) + { try { + if( s.size() ) { + datastream ds( s.data(), size_t(s.size()) ); + raw::unpack(ds,tmp); + } + } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } + template inline void pack( char* d, uint32_t s, const T& v ) { datastream ds(d,s);