SOIL C++
C++ Unified Device Interface
|
#include <Hasher.h>
Public Member Functions | |
Hasher () | |
Constructor. More... | |
~Hasher () | |
Destructor. More... | |
template<typename T > | |
void | push_back (T x) |
Add data. More... | |
std::vector< unsigned char > | hash () |
Hash the data buffer. More... | |
void | reset () |
Reset data buffer. More... | |
size_t | size (void) |
Digest size. More... | |
Static Public Member Functions | |
static std::string | print (std::vector< unsigned char > bytes, bool uppercase=true) |
Print Bytestring. More... | |
static std::vector< unsigned char > | sha256 (const unsigned char *data, size_t length) |
SHA256 hash. More... | |
Class which provides an convenient interface for calculating SHA256 hashes. The underlying methods are taken from OpenSSL.
SIGN::Hasher::Hasher | ( | ) |
Default constructor, no special effort here.
Definition at line 19 of file Hasher.cpp.
SIGN::Hasher::~Hasher | ( | ) |
Default destructor, no special effort here.
Definition at line 24 of file Hasher.cpp.
std::vector< unsigned char > SIGN::Hasher::hash | ( | ) |
Calculate the SHA256 hash of the current data buffer and return it as standard vector of bytes. Internally calls the static SHA256 function
Definition at line 28 of file Hasher.cpp.
|
static |
Convenience function to pretty-print bytestrings in HEX format.
[in] | bytes | Data to print |
[in] | uppercase | Boolean flag whether to print uppercase |
Definition at line 43 of file Hasher.cpp.
|
inline |
Push back data to the internal buffer which eventually gets hashed. This function is implemented using templates, underneath it copies the raw bytes after casting.
T | Original type of the item to add to the buffer |
[in] | x | Item to add to the buffer |
void SIGN::Hasher::reset | ( | ) |
Clear the internal data buffer (i.e. to start with new data)
Definition at line 33 of file Hasher.cpp.
|
static |
Calculate the SHA256 hash of the given input data. Be careful to no pass invalid pointers here, there is a risk of memory leaks.
data | [in] Pointer to the memory block to read from |
length | [in] Length of the data to consume |
Definition at line 8 of file Hasher.cpp.
size_t SIGN::Hasher::size | ( | void | ) |
Convenience function to get the digest size, which is often needed when handling raw bytes.
Definition at line 38 of file Hasher.cpp.