Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sha512.hpp
Go to the documentation of this file.
1#pragma once
2#include <fc/fwd.hpp>
3#include <fc/string.hpp>
4
5namespace fc
6{
7
8class sha512
9{
10 public:
11 sha512();
12 explicit sha512( const string& hex_str );
13
14 string str()const;
15 operator string()const;
16
17 char* data();
18 const char* data()const;
19 size_t data_size()const { return 512 / 8; }
20
21 static sha512 hash( const char* d, uint32_t dlen );
22 static sha512 hash( const string& );
23
24 template<typename T>
25 static sha512 hash( const T& t )
26 {
28 e << t;
29 return e.result();
30 }
31
32 class encoder
33 {
34 public:
35 encoder();
36 ~encoder();
37
38 void write( const char* d, uint32_t dlen );
39 void put( char c ) { write( &c, 1 ); }
40 void reset();
41 sha512 result();
42
43 private:
44 struct impl;
46 };
47
48 template<typename T>
49 inline friend T& operator<<( T& ds, const sha512& ep ) {
50 ds.write( ep.data(), sizeof(ep) );
51 return ds;
52 }
53
54 template<typename T>
55 inline friend T& operator>>( T& ds, sha512& ep ) {
56 ds.read( ep.data(), sizeof(ep) );
57 return ds;
58 }
59 friend sha512 operator << ( const sha512& h1, uint32_t i );
60 friend bool operator == ( const sha512& h1, const sha512& h2 );
61 friend bool operator != ( const sha512& h1, const sha512& h2 );
62 friend sha512 operator ^ ( const sha512& h1, const sha512& h2 );
63 friend bool operator >= ( const sha512& h1, const sha512& h2 );
64 friend bool operator > ( const sha512& h1, const sha512& h2 );
65 friend bool operator < ( const sha512& h1, const sha512& h2 );
66
68};
69
71
72 class variant;
73 void to_variant( const sha512& bi, variant& v );
74 void from_variant( const variant& v, sha512& bi );
75
76} // fc
77
Used to forward declare value types.
Definition fwd.hpp:11
void put(char c)
Definition sha512.hpp:39
void write(const char *d, uint32_t dlen)
Definition sha512.cpp:46
static sha512 hash(const T &t)
Definition sha512.hpp:25
friend sha512 operator^(const sha512 &h1, const sha512 &h2)
Definition sha512.cpp:63
friend bool operator<(const sha512 &h1, const sha512 &h2)
Definition sha512.cpp:81
friend bool operator>=(const sha512 &h1, const sha512 &h2)
Definition sha512.cpp:75
friend bool operator!=(const sha512 &h1, const sha512 &h2)
Definition sha512.cpp:84
friend T & operator>>(T &ds, sha512 &ep)
Definition sha512.hpp:55
friend bool operator==(const sha512 &h1, const sha512 &h2)
Definition sha512.cpp:87
friend T & operator<<(T &ds, const sha512 &ep)
Definition sha512.hpp:49
string str() const
Definition sha512.cpp:19
uint64_t _hash[8]
Definition sha512.hpp:67
char * data()
Definition sha512.cpp:24
friend bool operator>(const sha512 &h1, const sha512 &h2)
Definition sha512.cpp:78
static sha512 hash(const char *d, uint32_t dlen)
Definition sha512.cpp:37
size_t data_size() const
Definition sha512.hpp:19
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
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
fc::sha512 uint512
Definition sha512.hpp:70
#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
CK_ULONG d