mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
f9cda74b58
- loader checks if resources are correct at startup, if not, downloads them and replaces - add sha256 to hash - change hash to use paths instead of strings - cmake rework; GeodeFile.cmake now checks CLI version - add optional `DONT_INSTALL` argument to `create_geode_file` - test mods are now not installed by default - add package_geode_resources_now command for packaging resources at configure time and creating a header with their calculated hashes
27 lines
881 B
C++
27 lines
881 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <fstream>
|
|
#include <ciso646>
|
|
#include "picosha3.h"
|
|
#include "picosha2.h"
|
|
#include <vector>
|
|
#include <fs/filesystem.hpp>
|
|
|
|
static std::string calculateSHA3_256(ghc::filesystem::path const& path) {
|
|
std::vector<uint8_t> s(picosha3::bits_to_bytes(256));
|
|
auto sha3_256 = picosha3::get_sha3_generator<256>();
|
|
std::ifstream file(path, std::ios::binary);
|
|
return sha3_256.get_hex_string(file);
|
|
}
|
|
|
|
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);
|
|
}
|