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