diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2022-12-02 16:34:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-02 16:34:53 +0100 |
| commit | e9b7c66a541636e72659fbfcc9a3f20a85f2bee8 (patch) | |
| tree | b65942799ff6267ebe29c8b64056819461621be7 /source/core/slang-digest-util.h | |
| parent | 92ae4949fe1af28ef31331fd4116c8111c057420 (diff) | |
Cleanup crypto utilities (#2549)
* Consolidate crypto functions into single module
* Migrate rest of code to new crypto module
* Fix name conflict
Diffstat (limited to 'source/core/slang-digest-util.h')
| -rw-r--r-- | source/core/slang-digest-util.h | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/source/core/slang-digest-util.h b/source/core/slang-digest-util.h deleted file mode 100644 index 1e272fd5e..000000000 --- a/source/core/slang-digest-util.h +++ /dev/null @@ -1,43 +0,0 @@ -// slang-digest-utils.h - Utility functions specifically designed to be used with slang::Digest -#pragma once -#include "../../slang.h" -#include "slang-string.h" - -namespace Slang -{ - using slang::Digest; - - struct DigestUtil - { - // Compute the digest for an UnownedStringSlice - static Digest computeDigestForStringSlice(UnownedStringSlice text); - - // Combines the two provided digests. - static Digest combine(const Digest& digestA, const Digest& digestB); - - // Returns the hash stored in digest as a String. - static String toString(const Digest& digest); - - // Returns the hash represented by hashString as a Digest. - static Digest fromString(UnownedStringSlice hashString); - }; - - inline StringBuilder& operator<<(StringBuilder& sb, const Digest& d) - { - // Must cast to uint8_t* first in order to correctly account for - // endianness. - uint8_t* uint8Hash = (uint8_t*)d.values; - - for (Index i = 0; i < 16; ++i) - { - int hashSegment = uint8Hash[i]; - // Check if we need to append a leading zero. - if (hashSegment < 16) - { - sb << "0"; - } - sb.append(hashSegment, 16); - } - return sb; - } -} |
