Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sha224.hpp
Go to the documentation of this file.
1#pragma once
2#include <unordered_map>
3#include <fc/fwd.hpp>
4#include <fc/io/raw_fwd.hpp>
5#include <fc/string.hpp>
6
7namespace fc
8{
9
10class sha224
11{
12 public:
13 sha224();
14 explicit sha224( const string& hex_str );
15
16 string str()const;
17 operator string()const;
18
19 char* data();
20 const char* data()const;
21 size_t data_size()const { return 224 / 8; }
22
23 static sha224 hash( const char* d, uint32_t dlen );
24 static sha224 hash( const string& );
25
26 template<typename T>
27 static sha224 hash( const T& t )
28 {
30 fc::raw::pack(e,t);
31 return e.result();
32 }
33
34 class encoder
35 {
36 public:
37 encoder();
38 ~encoder();
39
40 void write( const char* d, uint32_t dlen );
41 void put( char c ) { write( &c, 1 ); }
42 void reset();
43 sha224 result();
44
45 private:
46 struct impl;
48 };
49
50 template<typename T>
51 inline friend T& operator<<( T& ds, const sha224& ep ) {
52 static_assert( sizeof(ep) == (8*3+4), "sha224 size mismatch" );
53 ds.write( ep.data(), sizeof(ep) );
54 return ds;
55 }
56
57 template<typename T>
58 inline friend T& operator>>( T& ds, sha224& ep ) {
59 ds.read( ep.data(), sizeof(ep) );
60 return ds;
61 }
62 friend sha224 operator << ( const sha224& h1, uint32_t i );
63 friend bool operator == ( const sha224& h1, const sha224& h2 );
64 friend bool operator != ( const sha224& h1, const sha224& h2 );
65 friend sha224 operator ^ ( const sha224& h1, const sha224& h2 );
66 friend bool operator >= ( const sha224& h1, const sha224& h2 );
67 friend bool operator > ( const sha224& h1, const sha224& h2 );
68 friend bool operator < ( const sha224& h1, const sha224& h2 );
69 friend std::size_t hash_value( const sha224& v ) { return uint64_t(v._hash[1])<<32 | v._hash[2]; }
70
72};
73
74 class variant;
75 void to_variant( const sha224& bi, variant& v );
76 void from_variant( const variant& v, sha224& bi );
77
78} // fc
79namespace std
80{
81 template<>
82 struct hash<fc::sha224>
83 {
84 size_t operator()( const fc::sha224& s )const
85 {
86 return *((size_t*)&s);
87 }
88 };
89}
Used to forward declare value types.
Definition fwd.hpp:11
void write(const char *d, uint32_t dlen)
Definition sha224.cpp:45
void put(char c)
Definition sha224.hpp:41
static sha224 hash(const T &t)
Definition sha224.hpp:27
friend bool operator>(const sha224 &h1, const sha224 &h2)
Definition sha224.cpp:71
static sha224 hash(const char *d, uint32_t dlen)
Definition sha224.cpp:36
size_t data_size() const
Definition sha224.hpp:21
friend bool operator==(const sha224 &h1, const sha224 &h2)
Definition sha224.cpp:80
friend bool operator<(const sha224 &h1, const sha224 &h2)
Definition sha224.cpp:74
string str() const
Definition sha224.cpp:19
friend bool operator!=(const sha224 &h1, const sha224 &h2)
Definition sha224.cpp:77
friend T & operator<<(T &ds, const sha224 &ep)
Definition sha224.hpp:51
uint32_t _hash[7]
Definition sha224.hpp:71
friend std::size_t hash_value(const sha224 &v)
Definition sha224.hpp:69
friend T & operator>>(T &ds, sha224 &ep)
Definition sha224.hpp:58
char * data()
Definition sha224.cpp:24
friend sha224 operator^(const sha224 &h1, const sha224 &h2)
Definition sha224.cpp:62
friend bool operator>=(const sha224 &h1, const sha224 &h2)
Definition sha224.cpp:68
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
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
#define T(meth, val, expected)
#define FC_REFLECT_TYPENAME(TYPE)
Definition reflect.hpp:320
unsigned int uint32_t
Definition stdint.h:126
unsigned __int64 uint64_t
Definition stdint.h:136
size_t operator()(const fc::sha224 &s) const
Definition sha224.hpp:84
CK_ULONG d
char * s