Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
ripemd160.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <fc/fwd.hpp>
4#include <fc/io/raw_fwd.hpp>
6
7namespace fc{
8class sha512;
9class sha256;
10
12{
13 public:
14 ripemd160();
15 explicit ripemd160( const string& hex_str );
16
17 string str()const;
18 explicit operator string()const;
19
20 char* data()const;
21 size_t data_size()const { return 160/8; }
22
23 static ripemd160 hash( const fc::sha512& h );
24 static ripemd160 hash( const fc::sha256& h );
25 static ripemd160 hash( const char* d, uint32_t dlen );
26 static ripemd160 hash( const string& );
27
28 template<typename T>
29 static ripemd160 hash( const T& t )
30 {
32 fc::raw::pack(e,t);
33 return e.result();
34 }
35
36 class encoder
37 {
38 public:
39 encoder();
40 ~encoder();
41
42 void write( const char* d, uint32_t dlen );
43 void put( char c ) { write( &c, 1 ); }
44 void reset();
46
47 private:
48 struct impl;
50 };
51
52 template<typename T>
53 inline friend T& operator<<( T& ds, const ripemd160& ep ) {
54 ds.write( ep.data(), sizeof(ep) );
55 return ds;
56 }
57
58 template<typename T>
59 inline friend T& operator>>( T& ds, ripemd160& ep ) {
60 ds.read( ep.data(), sizeof(ep) );
61 return ds;
62 }
63 friend ripemd160 operator << ( const ripemd160& h1, uint32_t i );
64 friend bool operator == ( const ripemd160& h1, const ripemd160& h2 );
65 friend bool operator != ( const ripemd160& h1, const ripemd160& h2 );
66 friend ripemd160 operator ^ ( const ripemd160& h1, const ripemd160& h2 );
67 friend bool operator >= ( const ripemd160& h1, const ripemd160& h2 );
68 friend bool operator > ( const ripemd160& h1, const ripemd160& h2 );
69 friend bool operator < ( const ripemd160& h1, const ripemd160& h2 );
70
72};
73
74 class variant;
75 void to_variant( const ripemd160& bi, variant& v );
76 void from_variant( const variant& v, ripemd160& bi );
77
80
81 template<> struct get_typename<uint160_t> { static const char* name() { return "uint160_t"; } };
82
83} // namespace fc
84
85namespace std
86{
87 template<>
88 struct hash<fc::ripemd160>
89 {
90 size_t operator()( const fc::ripemd160& s )const
91 {
92 return *((size_t*)&s);
93 }
94 };
95}
Used to forward declare value types.
Definition fwd.hpp:11
void write(const char *d, uint32_t dlen)
Definition ripemd160.cpp:61
static ripemd160 hash(const T &t)
Definition ripemd160.hpp:29
friend bool operator>(const ripemd160 &h1, const ripemd160 &h2)
Definition ripemd160.cpp:90
string str() const
Definition ripemd160.cpp:23
friend bool operator!=(const ripemd160 &h1, const ripemd160 &h2)
Definition ripemd160.cpp:96
friend bool operator>=(const ripemd160 &h1, const ripemd160 &h2)
Definition ripemd160.cpp:87
friend bool operator<(const ripemd160 &h1, const ripemd160 &h2)
Definition ripemd160.cpp:93
friend ripemd160 operator^(const ripemd160 &h1, const ripemd160 &h2)
Definition ripemd160.cpp:78
friend T & operator>>(T &ds, ripemd160 &ep)
Definition ripemd160.hpp:59
uint32_t _hash[5]
Definition ripemd160.hpp:71
char * data() const
Definition ripemd160.cpp:28
static ripemd160 hash(const fc::sha512 &h)
Definition ripemd160.cpp:44
size_t data_size() const
Definition ripemd160.hpp:21
friend bool operator==(const ripemd160 &h1, const ripemd160 &h2)
Definition ripemd160.cpp:99
friend T & operator<<(T &ds, const ripemd160 &ep)
Definition ripemd160.hpp:53
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
namespace sysio::chain
Definition authority.cpp:3
std::string string
Definition string.hpp:10
ripemd160 uint160_t
Definition ripemd160.hpp:78
ripemd160 uint160
Definition ripemd160.hpp:79
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
Definition authority.cpp:4
Definition name.hpp:106
constexpr const char sha256[]
#define T(meth, val, expected)
unsigned int uint32_t
Definition stdint.h:126
static const char * name()
Definition ripemd160.hpp:81
size_t operator()(const fc::ripemd160 &s) const
Definition ripemd160.hpp:90
CK_ULONG d
char * s