diff --git a/inc/integretychecker.h b/inc/integretychecker.h index 04f9334..080cd74 100644 --- a/inc/integretychecker.h +++ b/inc/integretychecker.h @@ -13,7 +13,9 @@ public: bool saveKeyFile(const std::string &app); 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 generateFileHash(const std::string &filepath); diff --git a/src/integretychecker.cpp b/src/integretychecker.cpp index efb19a3..f95e2ac 100644 --- a/src/integretychecker.cpp +++ b/src/integretychecker.cpp @@ -156,3 +156,22 @@ bool IntegretyCheck::verifyHashList(const std::string &signedHashList) { 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(); +}