2022-08-01 11:18:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
#include <ciso646>
|
|
|
|
#include "picosha3.h"
|
2022-10-14 14:04:59 -04:00
|
|
|
#include "picosha2.h"
|
2022-08-01 11:18:03 -04:00
|
|
|
#include <vector>
|
2022-10-14 14:04:59 -04:00
|
|
|
#include <fs/filesystem.hpp>
|
2022-08-01 11:18:03 -04:00
|
|
|
|
2022-10-14 14:04:59 -04:00
|
|
|
static std::string calculateSHA3_256(ghc::filesystem::path const& path) {
|
2022-08-01 11:18:03 -04:00
|
|
|
std::vector<uint8_t> s(picosha3::bits_to_bytes(256));
|
|
|
|
auto sha3_256 = picosha3::get_sha3_generator<256>();
|
2022-10-11 16:31:16 -04:00
|
|
|
std::ifstream file(path, std::ios::binary);
|
2022-08-01 11:18:03 -04:00
|
|
|
return sha3_256.get_hex_string(file);
|
|
|
|
}
|
2022-10-14 14:04:59 -04:00
|
|
|
|
|
|
|
static std::string calculateSHA256(ghc::filesystem::path const& path) {
|
|
|
|
std::vector<uint8_t> hash(picosha2::k_digest_size);
|
|
|
|
std::ifstream file(path, std::ios::binary);
|
|
|
|
picosha2::hash256(file, hash.begin(), hash.end());
|
|
|
|
return picosha2::bytes_to_hex_string(hash.begin(), hash.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string calculateHash(ghc::filesystem::path const& path) {
|
|
|
|
return calculateSHA3_256(path);
|
|
|
|
}
|