From e9b7c66a541636e72659fbfcc9a3f20a85f2bee8 Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Fri, 2 Dec 2022 16:34:53 +0100 Subject: Cleanup crypto utilities (#2549) * Consolidate crypto functions into single module * Migrate rest of code to new crypto module * Fix name conflict --- source/core/slang-digest-builder.h | 117 ------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 source/core/slang-digest-builder.h (limited to 'source/core/slang-digest-builder.h') diff --git a/source/core/slang-digest-builder.h b/source/core/slang-digest-builder.h deleted file mode 100644 index c613b2239..000000000 --- a/source/core/slang-digest-builder.h +++ /dev/null @@ -1,117 +0,0 @@ -#pragma once -#include "slang-md5.h" -#include "../../slang.h" -#include "../core/slang-string.h" -#include "../core/slang-list.h" - -namespace Slang -{ - using slang::Digest; - - // Wrapper struct that holds objects necessary for hashing. - struct DigestBuilder - { - public: - DigestBuilder() - { - hashGen.init(&context); - } - - template::value || std::is_enum::value, int>::type = 0> - DigestBuilder& operator<<(const T value) - { - append(value); - return *this; - } - - DigestBuilder& operator<<(const String& str) - { - append(str); - return *this; - } - - DigestBuilder& operator<<(const StringSlice& str) - { - append(str); - return *this; - } - - DigestBuilder& operator<<(const UnownedStringSlice& str) - { - append(str); - return *this; - } - - DigestBuilder& operator<<(ISlangBlob* blob) - { - append(blob); - return *this; - } - - DigestBuilder& operator<<(const slang::Digest& digest) - { - append(digest); - return *this; - } - - template::value, int>::type = 0> - DigestBuilder& operator<<(const List& list) - { - append(list); - return *this; - } - - void append(const void* data, SlangInt size) - { - hashGen.update(&context, data, size); - } - - template::value || std::is_enum::value, int>::type = 0> - void append(const T value) - { - append(&value, sizeof(T)); - } - - void append(const String& str) - { - append(str.getBuffer(), str.getLength()); - } - - void append(const StringSlice& str) - { - append(str.begin(), str.getLength()); - } - - void append(const UnownedStringSlice& str) - { - append(str.begin(), str.getLength()); - } - - void append(ISlangBlob* blob) - { - append(blob->getBufferPointer(), blob->getBufferSize()); - } - - void append(const slang::Digest& digest) - { - append(&digest, sizeof(digest)); - } - - template::value, int>::type = 0> - void append(const List& list) - { - append(list.getBuffer(), list.getCount() * sizeof(T)); - } - - Digest finalize() - { - Digest hash; - hashGen.finalize(&context, &hash); - return hash; - } - - private: - MD5HashGen hashGen; - MD5Context context; - }; -} -- cgit v1.2.3