#pragma once #include #include #include #include "fs.h" namespace crypto { struct hash; } namespace tools { // Calculates sha256 checksum of the given data bool sha256sum_str(std::string_view str, crypto::hash& hash); // Calculates sha256 checksum of the given data, for non-char string_view (e.g. // basic_string_view or basic_string_view). template < typename Char, std::enable_if_t, int> = 0> bool sha256sum_str(std::basic_string_view str, crypto::hash& hash) { return sha256sum_str( std::string_view{reinterpret_cast(str.data()), str.size()}, hash); } // Calculates sha256 checksum of the given byte data given any arbitrary size-1 value pointer and // byte length. template = 0> bool sha256sum_str(const Char* data, size_t len, crypto::hash& hash) { return sha256sum_str(std::string_view{reinterpret_cast(data), len}, hash); } // Opens the given file and calculates a sha256sum of its contents bool sha256sum_file(const fs::path& filename, crypto::hash& hash); } // namespace tools