diff options
Diffstat (limited to 'Source/cmCryptoHash.cxx')
-rw-r--r-- | Source/cmCryptoHash.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index ff9ab0f..55e3a5b 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCryptoHash.h" +#include <cassert> + #include <cm/memory> #include <cm3p/kwiml/int.h> @@ -80,6 +82,37 @@ std::unique_ptr<cmCryptoHash> cmCryptoHash::New(cm::string_view algo) return std::unique_ptr<cmCryptoHash>(nullptr); } +std::string cmCryptoHash::GetHashAlgoName() const +{ +#ifndef CMAKE_USE_SYSTEM_LIBRHASH + static_assert(RHASH_HASH_COUNT == 10, "Update switch statement!"); +#endif + switch (this->Id) { + case RHASH_MD5: + return "MD5"; + case RHASH_SHA1: + return "SHA1"; + case RHASH_SHA224: + return "SHA224"; + case RHASH_SHA256: + return "SHA256"; + case RHASH_SHA384: + return "SHA384"; + case RHASH_SHA512: + return "SHA512"; + case RHASH_SHA3_224: + return "SHA3_224"; + case RHASH_SHA3_256: + return "SHA3_256"; + case RHASH_SHA3_384: + return "SHA3_384"; + case RHASH_SHA3_512: + return "SHA3_512"; + } + assert(false); + return "UNKNOWN"; +} + bool cmCryptoHash::IntFromHexDigit(char input, char& output) { if (input >= '0' && input <= '9') { |