Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Binary file compare
Forum Updated to NodeBB v4.3 + New Features

[Solved] Binary file compare

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    avmg
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      How about checking the md5 ?

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        avmg
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          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.

          157

          1 Reply Last reply
          0
          • A Offline
            A Offline
            avmg
            wrote on last edited by
            #5

            Sounds great!!

            I will try it!

            Thanks p3c0!

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              You're Welcome :) Happy Coding

              157

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved