aboutsummaryrefslogtreecommitdiff
path: root/src/Hash.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-03-09 10:26:55 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commit0e62cb8e5ed06d906ad84321cdda22acfcc952c9 (patch)
tree9ba0cc8e20febb4bf07d4d065e3d653ed651bdda /src/Hash.cpp
parenteda9a7bbefc5587bf1ff895a9214f450e64575fa (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);