From fafacbb87b0acf48420a3e6d5e2e3793f037956e Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 4 Jan 2023 15:32:43 -0500 Subject: [PATCH] LibCrypto: Add equality operators for Crypto::Hash::Digest<> --- Userland/Libraries/LibCrypto/Hash/HashFunction.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibCrypto/Hash/HashFunction.h b/Userland/Libraries/LibCrypto/Hash/HashFunction.h index 894f30f45f..2e91f6c44e 100644 --- a/Userland/Libraries/LibCrypto/Hash/HashFunction.h +++ b/Userland/Libraries/LibCrypto/Hash/HashFunction.h @@ -23,6 +23,9 @@ struct Digest { [[nodiscard]] ALWAYS_INLINE size_t data_length() const { return Size; } [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const { return { immutable_data(), data_length() }; } + + [[nodiscard]] bool operator==(Digest const& other) const { return memcmp(data, other.data, sizeof(data)) == 0; } + [[nodiscard]] bool operator!=(Digest const& other) const { return !(*this == other); } }; template>