From 0e62cb8e5ed06d906ad84321cdda22acfcc952c9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 9 Mar 2018 10:26:55 +0100 Subject: Partially implement 'add' operation --- src/Hash.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/Hash.cpp') diff --git a/src/Hash.cpp b/src/Hash.cpp index 5d2f914..91bc062 100644 --- a/src/Hash.cpp +++ b/src/Hash.cpp @@ -17,15 +17,6 @@ namespace odhtdb static SodiumInitializer __sodiumInitializer; - // 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; - } - Hash::Hash() { memset(data, 0, HASH_BYTE_SIZE); @@ -38,6 +29,11 @@ namespace odhtdb throw HashException("Failed to hash data using blake2b"); } + Hash::Hash(const Hash &other) + { + memcpy(data, other.data, HASH_BYTE_SIZE); + } + size_t Hash::operator()() const { return fnvHash((const unsigned char*)data, HASH_BYTE_SIZE); -- cgit v1.2.3