add load/save hashFile function

master
Arne Schroeder 2019-09-07 13:25:56 +02:00
parent 275a90f658
commit c08b34ddbf
2 changed files with 22 additions and 1 deletions

View File

@ -13,7 +13,9 @@ public:
bool saveKeyFile(const std::string &app); bool saveKeyFile(const std::string &app);
bool generateKeyPair(); bool generateKeyPair();
std::string loadHashList(const std::string &hashList); std::string loadHashList(const std::string &app);
void saveHashList(const std::string &app, const std::string &hashList);
std::string generateHashList(const std::string &app); std::string generateHashList(const std::string &app);
std::string generateFileHash(const std::string &filepath); std::string generateFileHash(const std::string &filepath);

View File

@ -156,3 +156,22 @@ bool IntegretyCheck::verifyHashList(const std::string &signedHashList) {
return result; return result;
} }
std::string IntegretyCheck::loadHashList(const std::string &app) {
std::stringstream content;
fs::path appPath(app);
std::ifstream in(appPath / HASH_FILE, std::ios::in | std::ios::binary);
if (in) {
content << in.rdbuf();
in.close();
}
return content.str();
}
void IntegretyCheck::saveHashList(const std::string &app,
const std::string &hashList) {
fs::path appPath(app);
std::ofstream out(appPath / HASH_FILE);
out << hashList;
out.close();
}