AchievementManager: APPROVED_LIST_HASH quality of life improvements

APPROVED_LIST_HASH is moved to a separate file, making tests compilation faster after changing it.
The error message prints the hash in a way that it can be directly copy-pasted (though it still needs clang-format).
This commit is contained in:
Martino Fontana
2026-01-23 10:05:19 +01:00
parent 981b7df420
commit a108fb849f
8 changed files with 39 additions and 29 deletions
+7 -12
View File
@@ -7,6 +7,7 @@
#include <array>
#include <memory>
#include <fmt/ranges.h>
#include <mbedtls/sha1.h>
#include "Common/Assert.h"
@@ -390,17 +391,11 @@ Digest CalculateDigest(const u8* msg, size_t len)
std::string DigestToString(const Digest& digest)
{
static constexpr std::array<char, 16> lookup = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
std::string hash;
hash.reserve(digest.size() * 2);
for (size_t i = 0; i < digest.size(); ++i)
{
const u8 upper = static_cast<u8>((digest[i] >> 4) & 0xf);
const u8 lower = static_cast<u8>(digest[i] & 0xf);
hash.push_back(lookup[upper]);
hash.push_back(lookup[lower]);
}
return hash;
return fmt::format("{:02X}", fmt::join(digest, ""));
}
std::string DigestToSource(const Digest& digest)
{
return fmt::format("{{0x{:02X}}}", fmt::join(digest, ", 0x"));
}
} // namespace Common::SHA1