From 52dc6e82e94f11047e907e04a64d13fd877d4e49 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 27 Aug 2024 16:52:18 +0200 Subject: Implement HashInfo class ...that validates hashes and stores some additional information about them. --- src/utils/cpp/hex_string.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/utils/cpp/hex_string.hpp') diff --git a/src/utils/cpp/hex_string.hpp b/src/utils/cpp/hex_string.hpp index 23544d49..4b0124c4 100644 --- a/src/utils/cpp/hex_string.hpp +++ b/src/utils/cpp/hex_string.hpp @@ -15,6 +15,8 @@ #ifndef INCLUDED_SRC_UTILS_CPP_HEX_STRING_HPP #define INCLUDED_SRC_UTILS_CPP_HEX_STRING_HPP +#include +#include #include #include #include @@ -22,6 +24,12 @@ #include #include +[[nodiscard]] static inline auto IsHexString(std::string const& s) noexcept + -> bool { + return std::all_of( + s.begin(), s.end(), [](unsigned char c) { return std::isxdigit(c); }); +} + [[nodiscard]] static inline auto ToHexString(std::string const& bytes) -> std::string { std::ostringstream ss{}; -- cgit v1.2.3