diff options
| author | Stefan Boberg <[email protected]> | 2021-05-25 09:54:09 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-25 09:54:09 +0200 |
| commit | 882e93e4786f9e67e0edf6c276b16bb40848bae9 (patch) | |
| tree | c5d4c45679c676c6aeb804c7601f43340b78ea0b /zencore/blake3.cpp | |
| parent | Updated structured cache description (diff) | |
| parent | Compile out all rocksdb code for a smaller binary (diff) | |
| download | zen-882e93e4786f9e67e0edf6c276b16bb40848bae9.tar.xz zen-882e93e4786f9e67e0edf6c276b16bb40848bae9.zip | |
Merged from origin/main
Diffstat (limited to 'zencore/blake3.cpp')
| -rw-r--r-- | zencore/blake3.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/zencore/blake3.cpp b/zencore/blake3.cpp index ec5d496d5..090eb6897 100644 --- a/zencore/blake3.cpp +++ b/zencore/blake3.cpp @@ -2,10 +2,11 @@ #include <zencore/blake3.h> +#include <zencore/compositebuffer.h> #include <zencore/string.h> #include <zencore/zencore.h> -#include "../3rdparty/BLAKE3/c/blake3.h" +#include "../3rdparty/BLAKE3/c/blake3.h" #pragma comment(lib, "blake3.lib") #include <doctest/doctest.h> @@ -36,6 +37,24 @@ BLAKE3::HashMemory(const void* data, size_t byteCount) } BLAKE3 +BLAKE3::HashBuffer(const CompositeBuffer& Buffer) +{ + BLAKE3 Hash; + + blake3_hasher Hasher; + blake3_hasher_init(&Hasher); + + for (const SharedBuffer& Segment : Buffer.GetSegments()) + { + blake3_hasher_update(&Hasher, Segment.GetData(), Segment.GetSize()); + } + + blake3_hasher_finalize(&Hasher, Hash.Hash, sizeof Hash.Hash); + + return Hash; +} + +BLAKE3 BLAKE3::FromHexString(const char* string) { BLAKE3 b3; |