Util: add de_hex() fun
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-30 21:56:20 +01:00
parent dc1ab343eb
commit fa9dc26f66
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

13
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<CryptoPP::byte*>(s.data()), s.size());
decoder.MessageEnd();
dst.resize(gen_block_size);
decoder.Get(reinterpret_cast<CryptoPP::byte*>(&dst[0]), dst.size());
return dst;
}
static auto do_sha(const std::string& str_to_hash) -> const std::string {
// do sha256
std::string digest;