From 6807b8309e10938eb4d5dcfeb29c66bf7f1cdd76 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 2 Sep 2021 12:58:15 +0200 Subject: Added HashMemory() function accepting CompositeBuffer argument --- zencore/iohash.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'zencore/iohash.cpp') 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 #include +#include #include #include @@ -23,6 +24,19 @@ IoHash::HashMemory(const void* data, size_t byteCount) return io; } +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) { -- cgit v1.2.3