26 template<
typename Algo = CryptoPP::SHA256>
27 static std::array<byte, Algo::DIGESTSIZE>
bytes(
const byte *buffer,
const std::size_t buffSize) {
28 std::array<byte, Algo::DIGESTSIZE> out{};
30 const CryptoPP::ArraySource vs(buffer, buffSize,
true,
new CryptoPP::HashFilter(algo,
new CryptoPP::ArraySink(out.data(), out.size())));
34 template<
typename Algo = CryptoPP::SHA256>
35 static std::array<byte, Algo::DIGESTSIZE>
bytes(
const std::vector<byte>& buffer) {
39 template<
typename Algo = CryptoPP::SHA256>
43 const CryptoPP::VectorSource
vs(
buffer,
true,
new CryptoPP::HashFilter(algo,
new CryptoPP::HexEncoder(
new CryptoPP::StringSink(
out),
uppercase)));
47 template<
typename Algo = CryptoPP::SHA256>
50 std::array<byte, Algo::DIGESTSIZE>
out{};
56 const CryptoPP::FileSource
fs(
file,
58 new CryptoPP::HashFilter(algo,
new CryptoPP::ArraySink(
out.data(),
out.size())));
63 std::array<byte, Algo::DIGESTSIZE>
out{};
65 new CryptoPP::HashFilter(
67 new CryptoPP::ArraySink(
out.data(),
out.size())));
70 std::array<byte, Algo::DIGESTSIZE>
out{};
76 algo.Final(
out.data());
81 template<
typename Algo = CryptoPP::SHA256>
88 const CryptoPP::FileSource
fs(
file,
true,
new CryptoPP::HashFilter(
Algo(),
new CryptoPP::HexEncoder(
new CryptoPP::StringSink(
out),
uppercase)));
96 new CryptoPP::HashFilter(
98 new CryptoPP::HexEncoder(
99 new CryptoPP::StringSink(
out),
107 template<
typename Algo = CryptoPP::SHA256>
108 static std::string
stringify(
const std::array<byte, Algo::DIGESTSIZE>& hash,
const bool uppercase =
false) {
109 std::ostringstream
out{};
111 out << std::uppercase;
112 for (
const byte digest : hash) {
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
#define ENIGMA_STATIC_CLASS(Class)
Makes a class static, which will prevent creating instances from it and only use it as Class::Func()....
#define ENIGMA_ASSERT_OR_THROW(x, msg)
static void ReadChunks(const fs::path &filename, const std::size_t max_chunk_size, const std::function< bool(std::vector< byte > &&)> &callback)
static std::array< byte, Algo::DIGESTSIZE > bytes(const byte *buffer, const std::size_t buffSize)
static std::string stringify(const std::array< byte, Algo::DIGESTSIZE > &hash, const bool uppercase=false)
static std::array< byte, Algo::DIGESTSIZE > bytes(const std::vector< byte > &buffer)
static std::string str(const std::vector< byte > &buffer, const bool uppercase=false)
static std::string fileStr(const fs::path &filename, const bool uppercase=false)
static std::array< byte, Algo::DIGESTSIZE > fileBytes(const fs::path &filename)