[Solved] Binary file compare



  • 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


  • Moderators

    Hi,

    How about checking the md5 ?



  • 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!


  • Moderators

    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.



  • Sounds great!!

    I will try it!

    Thanks p3c0!


  • Moderators

    You're Welcome :) Happy Coding


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.