1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:08:12 +00:00

LibCrypto: Add a Hash::Manager that can act as any one of the hashes

This commit is contained in:
AnotherTest 2020-04-25 05:06:33 +04:30 committed by Andreas Kling
parent e997661e26
commit 43a49f5fff
6 changed files with 338 additions and 17 deletions

View file

@ -37,7 +37,7 @@ template<size_t BlockS, typename DigestT>
class HashFunction {
public:
static constexpr auto BlockSize = BlockS / 8;
static constexpr auto DigestSize = sizeof(DigestT);
static constexpr auto DigestSize = DigestT::Size;
using DigestType = DigestT;
@ -45,8 +45,8 @@ public:
static size_t digest_size() { return DigestSize; };
virtual void update(const u8*, size_t) = 0;
virtual void update(const ByteBuffer& buffer) = 0;
virtual void update(const StringView& string) = 0;
virtual void update(const ByteBuffer& buffer) { update(buffer.data(), buffer.size()); };
virtual void update(const StringView& string) { update((const u8*)string.characters_without_null_termination(), string.length()); };
virtual DigestType peek() = 0;
virtual DigestType digest() = 0;