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

#include <sha512.hpp>

Classes

class  encoder
 

Public Member Functions

 sha512 ()
 
 sha512 (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 sha512 hash (const char *d, uint32_t dlen)
 
static sha512 hash (const string &)
 
template<typename T >
static sha512 hash (const T &t)
 

Public Attributes

uint64_t _hash [8]
 

Friends

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

Detailed Description

Definition at line 8 of file sha512.hpp.

Constructor & Destructor Documentation

◆ sha512() [1/2]

fc::sha512::sha512 ( )

Definition at line 12 of file sha512.cpp.

12{ memset( _hash, 0, sizeof(_hash) ); }
uint64_t _hash[8]
Definition sha512.hpp:67
memset(pInfo->slotDescription, ' ', 64)
Here is the call graph for this function:

◆ sha512() [2/2]

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

Definition at line 13 of file sha512.cpp.

13 {
14 auto bytes_written = fc::from_hex( hex_str, (char*)_hash, sizeof(_hash) );
15 if( bytes_written < sizeof(_hash) )
16 memset( (char*)_hash + bytes_written, 0, (sizeof(_hash) - bytes_written) );
17 }
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::sha512::data ( )

Definition at line 24 of file sha512.cpp.

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

◆ data() [2/2]

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

Definition at line 25 of file sha512.cpp.

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

◆ data_size()

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

Definition at line 19 of file sha512.hpp.

19{ return 512 / 8; }

◆ hash() [1/3]

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

Definition at line 37 of file sha512.cpp.

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

◆ hash() [2/3]

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

Definition at line 42 of file sha512.cpp.

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

◆ hash() [3/3]

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

Definition at line 25 of file sha512.hpp.

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

◆ operator string()

fc::sha512::operator string ( ) const

Definition at line 22 of file sha512.cpp.

22{ return str(); }
string str() const
Definition sha512.cpp:19

◆ str()

string fc::sha512::str ( ) const

Definition at line 19 of file sha512.cpp.

19 {
20 return fc::to_hex( (char*)_hash, sizeof(_hash) );
21 }
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 sha512 & h1,
const sha512 & h2 )
friend

Definition at line 84 of file sha512.cpp.

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

◆ operator<

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

Definition at line 81 of file sha512.cpp.

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

◆ operator<< [1/2]

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

Definition at line 58 of file sha512.cpp.

58 {
59 sha512 result;
60 fc::detail::shift_l( h1.data(), result.data(), result.data_size(), i );
61 return result;
62 }

◆ operator<< [2/2]

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

Definition at line 49 of file sha512.hpp.

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

◆ operator==

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

Definition at line 87 of file sha512.cpp.

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

◆ operator>

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

Definition at line 78 of file sha512.cpp.

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

◆ operator>=

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

Definition at line 75 of file sha512.cpp.

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

◆ operator>>

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

Definition at line 55 of file sha512.hpp.

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

◆ operator^

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

Definition at line 63 of file sha512.cpp.

63 {
64 sha512 result;
65 result._hash[0] = h1._hash[0] ^ h2._hash[0];
66 result._hash[1] = h1._hash[1] ^ h2._hash[1];
67 result._hash[2] = h1._hash[2] ^ h2._hash[2];
68 result._hash[3] = h1._hash[3] ^ h2._hash[3];
69 result._hash[4] = h1._hash[4] ^ h2._hash[4];
70 result._hash[5] = h1._hash[5] ^ h2._hash[5];
71 result._hash[6] = h1._hash[6] ^ h2._hash[6];
72 result._hash[7] = h1._hash[7] ^ h2._hash[7];
73 return result;
74 }

Member Data Documentation

◆ _hash

uint64_t fc::sha512::_hash[8]

Definition at line 67 of file sha512.hpp.


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