diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-03-09 10:26:55 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 0e62cb8e5ed06d906ad84321cdda22acfcc952c9 (patch) | |
tree | 9ba0cc8e20febb4bf07d4d065e3d653ed651bdda /include/Hash.hpp | |
parent | eda9a7bbefc5587bf1ff895a9214f450e64575fa (diff) |
Partially implement 'add' operation
Diffstat (limited to 'include/Hash.hpp')
-rw-r--r-- | include/Hash.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/Hash.hpp b/include/Hash.hpp index d7c90b0..bd87b69 100644 --- a/include/Hash.hpp +++ b/include/Hash.hpp @@ -1,7 +1,6 @@ #pragma once #include "utils.hpp" -#include <sodium/crypto_generichash_blake2b.h> #include <stdexcept> #include <unordered_map> @@ -9,6 +8,15 @@ namespace odhtdb { const int HASH_BYTE_SIZE = 32; + // Source: https://stackoverflow.com/a/11414104 (public license) + static size_t fnvHash(const unsigned char *key, int len) + { + size_t h = 2166136261; + for (int i = 0; i < len; i++) + h = (h * 16777619) ^ key[i]; + return h; + } + class HashException : public std::runtime_error { public: @@ -21,6 +29,7 @@ namespace odhtdb Hash(); // Throws HashException on failure Hash(const void *input, const size_t inputSize); + Hash(const Hash &other); void* getData() const { return (void*)data; } size_t getSize() const { return HASH_BYTE_SIZE; } |