Added different hash func

This commit is contained in:
Vladislav Khorev committed 2026-02-10 21:06:21 +03:00
1 parent 251a59ddbe
commit 210c191d41
8 files changed
+39 -14

No files matched your search

+2 -2
View File
@@ -140,7 +140,7 @@ public:
std::string receivedHashStr = fullMessage.substr(hashPos + 6); // 6 — длина "#hash:"
// Вычисляем ожидаемый хеш от контента
size_t expectedHash = std::hash<std::string>{}(originalContent + NET_SECRET);
size_t expectedHash = fnv1a_hash(originalContent + NET_SECRET);
std::stringstream ss;
ss << std::hex << expectedHash;
@@ -323,7 +323,7 @@ private:
void process_message(const std::string& msg) {
if (!IsMessageValid(msg)) {
// Логируем попытку подмены и просто выходим из обработки
std::cout << "[Security] Invalid packet hash. Dropping message." << std::endl;
std::cout << "[Security] Invalid packet hash. Dropping message: " << msg << std::endl;
return;
}
std::string cleanMessage = msg.substr(0, msg.find("#hash:"));