Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::sha1 Class Reference

#include <sha1.hpp>

Classes

class  encoder
 

Public Member Functions

 sha1 ()
 
 sha1 (const string &hex_str)
 
string str () const
 
 operator string () const
 
char * data ()
 
const char * data () const
 
size_t data_size () const
 

Static Public Member Functions

static sha1 hash (const char *d, uint32_t dlen)
 
static sha1 hash (const string &)
 
template<typename T >
static sha1 hash (const T &t)
 

Public Attributes

uint32_t _hash [5]
 

Friends

template<typename T >
Toperator<< (T &ds, const sha1 &ep)
 
template<typename T >
Toperator>> (T &ds, sha1 &ep)
 
sha1 operator<< (const sha1 &h1, uint32_t i)
 
bool operator== (const sha1 &h1, const sha1 &h2)
 
bool operator!= (const sha1 &h1, const sha1 &h2)
 
sha1 operator^ (const sha1 &h1, const sha1 &h2)
 
bool operator>= (const sha1 &h1, const sha1 &h2)
 
bool operator> (const sha1 &h1, const sha1 &h2)
 
bool operator< (const sha1 &h1, const sha1 &h2)
 

Detailed Description

Definition at line 7 of file sha1.hpp.

Constructor & Destructor Documentation

◆ sha1() [1/2]

fc::sha1::sha1 ( )

Definition at line 13 of file sha1.cpp.

13{ memset( _hash, 0, sizeof(_hash) ); }
uint32_t _hash[5]
Definition sha1.hpp:66
memset(pInfo->slotDescription, ' ', 64)
Here is the call graph for this function:

◆ sha1() [2/2]

fc::sha1::sha1 ( const string & hex_str)
explicit

Definition at line 14 of file sha1.cpp.

14 {
15 auto bytes_written = fc::from_hex( hex_str, (char*)_hash, sizeof(_hash) );
16 if( bytes_written < sizeof(_hash) )
17 memset( (char*)_hash + bytes_written, 0, (sizeof(_hash) - bytes_written) );
18}
uint8_t from_hex(char c)
Definition hex.cpp:6
Here is the call graph for this function:

Member Function Documentation

◆ data() [1/2]

char * fc::sha1::data ( )

Definition at line 25 of file sha1.cpp.

25{ return (char*)&_hash[0]; }
Here is the caller graph for this function:

◆ data() [2/2]

const char * fc::sha1::data ( ) const

Definition at line 26 of file sha1.cpp.

26{ return (char*)&_hash[0]; }

◆ data_size()

size_t fc::sha1::data_size ( ) const
inline

Definition at line 18 of file sha1.hpp.

18{ return 20; }

◆ hash() [1/3]

sha1 fc::sha1::hash ( const char * d,
uint32_t dlen )
static

Definition at line 38 of file sha1.cpp.

38 {
39 encoder e;
40 e.write(d,dlen);
41 return e.result();
42}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash() [2/3]

sha1 fc::sha1::hash ( const string & s)
static

Definition at line 43 of file sha1.cpp.

43 {
44 return hash( s.c_str(), s.size() );
45}
static sha1 hash(const char *d, uint32_t dlen)
Definition sha1.cpp:38
char * s
Here is the call graph for this function:

◆ hash() [3/3]

template<typename T >
static sha1 fc::sha1::hash ( const T & t)
inlinestatic

Definition at line 24 of file sha1.hpp.

25 {
26 sha1::encoder e;
27 e << t;
28 return e.result();
29 }
Here is the call graph for this function:

◆ operator string()

fc::sha1::operator string ( ) const

Definition at line 23 of file sha1.cpp.

23{ return str(); }
string str() const
Definition sha1.cpp:20

◆ str()

string fc::sha1::str ( ) const

Definition at line 20 of file sha1.cpp.

20 {
21 return fc::to_hex( (char*)_hash, sizeof(_hash) );
22}
fc::string to_hex(const char *d, uint32_t s)
Definition hex.cpp:17
Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const sha1 & h1,
const sha1 & h2 )
friend

Definition at line 82 of file sha1.cpp.

82 {
83 return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) != 0;
84}

◆ operator<

bool operator< ( const sha1 & h1,
const sha1 & h2 )
friend

Definition at line 79 of file sha1.cpp.

79 {
80 return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) < 0;
81}

◆ operator<< [1/2]

sha1 operator<< ( const sha1 & h1,
uint32_t i )
friend

Definition at line 59 of file sha1.cpp.

59 {
60 sha1 result;
61 fc::detail::shift_l( h1.data(), result.data(), result.data_size(), i );
62 return result;
63}
sha1()
Definition sha1.cpp:13

◆ operator<< [2/2]

template<typename T >
T & operator<< ( T & ds,
const sha1 & ep )
friend

Definition at line 48 of file sha1.hpp.

48 {
49 ds.write( ep.data(), sizeof(ep) );
50 return ds;
51 }
static const Segment ds(Segment::ds)

◆ operator==

bool operator== ( const sha1 & h1,
const sha1 & h2 )
friend

Definition at line 85 of file sha1.cpp.

85 {
86 return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) == 0;
87}

◆ operator>

bool operator> ( const sha1 & h1,
const sha1 & h2 )
friend

Definition at line 76 of file sha1.cpp.

76 {
77 return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) > 0;
78}

◆ operator>=

bool operator>= ( const sha1 & h1,
const sha1 & h2 )
friend

Definition at line 73 of file sha1.cpp.

73 {
74 return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) >= 0;
75}

◆ operator>>

template<typename T >
T & operator>> ( T & ds,
sha1 & ep )
friend

Definition at line 54 of file sha1.hpp.

54 {
55 ds.read( ep.data(), sizeof(ep) );
56 return ds;
57 }

◆ operator^

sha1 operator^ ( const sha1 & h1,
const sha1 & h2 )
friend

Definition at line 64 of file sha1.cpp.

64 {
65 sha1 result;
66 result._hash[0] = h1._hash[0] ^ h2._hash[0];
67 result._hash[1] = h1._hash[1] ^ h2._hash[1];
68 result._hash[2] = h1._hash[2] ^ h2._hash[2];
69 result._hash[3] = h1._hash[3] ^ h2._hash[3];
70 result._hash[4] = h1._hash[4] ^ h2._hash[4];
71 return result;
72}

Member Data Documentation

◆ _hash

uint32_t fc::sha1::_hash[5]

Definition at line 66 of file sha1.hpp.


The documentation for this class was generated from the following files: