aboutsummaryrefslogtreecommitdiff
path: root/src/Hash.cpp
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-09 10:26:55 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-09 10:27:06 +0100
commit230e61091b401b8b2bb9496d557a15660fb5072b (patch)
tree13b937d93105c069d6478480c8a9ada45ccc2434 /src/Hash.cpp
parent2ffb47d0043e57707474e5ae811f97c2e5e93f25 (diff)
Partially implement 'add' operation
Diffstat (limited to 'src/Hash.cpp')
-rw-r--r--src/Hash.cpp14
1 files changed, 5 insertions, 9 deletions
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);