[Solved] Binary file compare
-
wrote on 21 Sept 2014, 14:33 last edited by
Hi everybody,
I have a small question, i need to compare two binary files and i want to compare if they are equal or not, i thought to check some properties like file size, but, What you recommend to compare if the content is equal??
Any suggestion??
Thanks!
Avmg -
Hi,
How about checking the md5 ?
-
wrote on 21 Sept 2014, 14:50 last edited by
I took a look about that and seems to be perfect!... But, Does it exist always??
I want to read these binary files from a logger but i didn't see anything about md5, How can i get this information?
Thanks!
-
AFAIK, md5 can be generated for any file.
bq. I want to read these binary files from a logger but i didn’t see anything about md5, How can i get this information?
Using Qt APIs you can do following:
@
QCryptographicHash md5gen(QCryptographicHash::Md5);
QFile file("myFile.pdf");
file.open(QIODevice::ReadOnly);
md5gen.addData(file.readAll());
file.close();
qDebug() << md5gen.result().toHex();
@Here md5 is calculated for a PDF file. Similarly it will work for other files too.
-
wrote on 21 Sept 2014, 15:09 last edited by
Sounds great!!
I will try it!
Thanks p3c0!
-
You're Welcome :) Happy Coding
1/6