diff options
author | Aleksi Lindeman <0xdec05eba@gmail.com> | 2018-03-09 10:26:55 +0100 |
---|---|---|
committer | Aleksi Lindeman <0xdec05eba@gmail.com> | 2018-03-09 10:27:06 +0100 |
commit | 230e61091b401b8b2bb9496d557a15660fb5072b (patch) | |
tree | 13b937d93105c069d6478480c8a9ada45ccc2434 /include/Hash.hpp | |
parent | 2ffb47d0043e57707474e5ae811f97c2e5e93f25 (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; } |