From fa9dc26f669dd1b5d7f11bbb3649890f80fd32a8 Mon Sep 17 00:00:00 2001 From: surtur Date: Sun, 30 Jan 2022 21:56:20 +0100 Subject: [PATCH] Util: add de_hex() fun --- util.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/util.h b/util.h index d7ec2bb..7c9a044 100644 --- a/util.h +++ b/util.h @@ -16,6 +16,19 @@ class Util final { public: static constexpr const std::size_t gen_block_size{32}; // 256 bits + static auto de_hex(const std::string& str) -> const std::string { + std::string s{str}; + std::string dst; + CryptoPP::HexDecoder decoder; + + decoder.Put(reinterpret_cast(s.data()), s.size()); + decoder.MessageEnd(); + dst.resize(gen_block_size); + decoder.Get(reinterpret_cast(&dst[0]), dst.size()); + + return dst; + } + static auto do_sha(const std::string& str_to_hash) -> const std::string { // do sha256 std::string digest;