aboutsummaryrefslogtreecommitdiff
path: root/zencore/iohash.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-02 12:58:15 +0200
committerStefan Boberg <[email protected]>2021-09-02 12:58:15 +0200
commit6807b8309e10938eb4d5dcfeb29c66bf7f1cdd76 (patch)
treeecfa54df804937dd60c66d8a548ebf52a34a4f25 /zencore/iohash.cpp
parentCompactBinary: Restricted compact binary attachments to objects to simplify p... (diff)
downloadzen-6807b8309e10938eb4d5dcfeb29c66bf7f1cdd76.tar.xz
zen-6807b8309e10938eb4d5dcfeb29c66bf7f1cdd76.zip
Added HashMemory() function accepting CompositeBuffer argument
Diffstat (limited to 'zencore/iohash.cpp')
-rw-r--r--zencore/iohash.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/zencore/iohash.cpp b/zencore/iohash.cpp
index afe2e54ba..9b095ccdb 100644
--- a/zencore/iohash.cpp
+++ b/zencore/iohash.cpp
@@ -3,6 +3,7 @@
#include <zencore/iohash.h>
#include <zencore/blake3.h>
+#include <zencore/compositebuffer.h>
#include <zencore/string.h>
#include <doctest/doctest.h>
@@ -24,6 +25,19 @@ IoHash::HashMemory(const void* data, size_t byteCount)
}
IoHash
+IoHash::HashMemory(const CompositeBuffer& Buffer)
+{
+ IoHashStream Hasher;
+
+ for (const SharedBuffer& Segment : Buffer.GetSegments())
+ {
+ Hasher.Append(Segment.GetData(), Segment.GetSize());
+ }
+
+ return Hasher.GetHash();
+}
+
+IoHash
IoHash::FromHexString(const char* string)
{
return FromHexString({string, sizeof(IoHash::Hash) * 2});