SOIL C++
C++ Unified Device Interface
Hasher.h
Go to the documentation of this file.
1#pragma once
2#include "constants.h"
3#include <vector>
4#include <string>
5
6namespace SIGN
7{
14 class DLL Hasher
15 {
16 private:
22 std::vector<unsigned char> data;
23 public:
29 Hasher();
30
36 ~Hasher();
37
47 template <typename T> void push_back(T x);
48
57 std::vector<unsigned char> hash();
58
64 void reset();
65
72 size_t size(void);
73
83 static std::string print(std::vector<unsigned char> bytes, bool uppercase = true);
84
95 static std::vector<unsigned char> sha256(const unsigned char* data, size_t length);
96 };
97
98 template<typename T>
99 inline void Hasher::push_back(T x)
100 {
101 unsigned char* pointer = reinterpret_cast<unsigned char*>(&x);
102 for (int i = 0; i < sizeof(T); i++)
103 {
104 data.push_back(pointer[i]);
105 }
106 }
107}
SHA256 Hasher.
Definition: Hasher.h:15
void push_back(T x)
Add data.
Definition: Hasher.h:99
Definition: Hasher.h:7