I would like to save a md5 of a image file in a database so when a user sends another image I would like to be able to compare if the image already exists in the database, I have to know if theres already one of those in the database, I thought the easiest way would be to md5 the content of a file and then compare with the md5 output to see if they are equal or not.
how could I do that? if you think this is not very good to do, you could suggest something else to compare images without having the original file present at the moment, that’s why I’m saving the md5 in the database.
I have the md5 function but I don’t know what to md5, my md5 function accept a std::string parameter and return the result as a std::string.
Thank you in advance.
I think MD5 is the way to go. Any image processing operation to compare images will probably take longer than the MD5 calculation.
Now, you need to break this operation into smaller steps:
1 – Read a file in binary mode into a
std::string:2 – Retrieve the MD5 of the file: