Fix bug in comparing hashes of files

This commit is contained in:
ozanarmagan 2023-06-23 10:45:55 +03:00
parent d8e51ce86a
commit 2517ac0ba7

View File

@ -116,8 +116,9 @@ const bool TextEmbedderManager::check_md5(const std::string& file_path, const st
std::stringstream ss,res;
ss << stream.rdbuf();
MD5((unsigned char*)ss.str().c_str(), ss.str().length(), md5);
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
res << std::hex << (int)md5[i];
// convert md5 to hex string with leading zeros
for(int i = 0; i < MD5_DIGEST_LENGTH; i++) {
res << std::hex << std::setfill('0') << std::setw(2) << (int)md5[i];
}
return res.str() == target_md5;
}