This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
fortuna/util.h
surtur 65c476dbd6
All checks were successful
continuous-integration/drone/push Build is passing
add Util class + perform general refactor
* rm duplicate do_sha() code, consolidate in Util
* make reseed() public so that it can be called from outside
* rm reseed() from do_crypto() where it has no place
2021-12-13 05:10:07 +01:00

36 lines
645 B
C++

#ifndef FORTUNA_UTIL_H
#define FORTUNA_UTIL_H
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <cryptopp/sha3.h>
namespace fortuna {
class Util final {
public:
static auto do_sha(const std::string& str_to_hash) -> const std::string {
// do sha256
std::string digest;
// no reason not to go for Keccak
CryptoPP::SHA3_256 sha3_256;
CryptoPP::StringSource str_src(str_to_hash, true,
new CryptoPP::HashFilter (
sha3_256, new CryptoPP::HexEncoder(
new CryptoPP::StringSink(digest), false))
);
return digest;
}
Util() = delete;
~Util() noexcept;
}; // class Util
} // namespace fortuna
#endif//FORTUNA_UTIL_H