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. QCryptographicHash::Md5 return a different value then md5sum linux command
QtWS25 Last Chance

QCryptographicHash::Md5 return a different value then md5sum linux command

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.5k Views
  • 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.
  • Catalin.OC Offline
    Catalin.OC Offline
    Catalin.O
    wrote on last edited by
    #1

    I'm playing with some script and building an server with socat to share some informations with QT client.

    Currently, I'm using:

    QByteArray d;
    d.append("BUSNUM=" + match.captured(4) + ";DEVNUM=" + match.captured(5) +
                        ";ACTION=" + match.captured(6) + ";ID_VENDOR_ENC=" + match.captured(7));
    QString md5 = QString(QCryptographicHash::hash(d,QCryptographicHash::Md5).toHex());
    

    Unfortunately, this value is different the one returned by md5sum linux command.

    For computing this value, is there something that should be written in a different way ?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      https://forum.qt.io/topic/39768/qcryptographichash-md5-vs-md5sum-solved/7

      Catalin.OC 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        https://forum.qt.io/topic/39768/qcryptographichash-md5-vs-md5sum-solved/7

        Catalin.OC Offline
        Catalin.OC Offline
        Catalin.O
        wrote on last edited by
        #3

        @mrjj Seems the same, but, when building the payload, I'm already using a redirection like:

        md5sum <<< payload

        mrjjM hskoglundH 2 Replies Last reply
        0
        • Catalin.OC Catalin.O

          @mrjj Seems the same, but, when building the payload, I'm already using a redirection like:

          md5sum <<< payload

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Catalin.O

          But the good news it should give same result if presented with same input so
          So check you
          QByteArray d;
          against your payload.

          Catalin.OC 1 Reply Last reply
          0
          • Catalin.OC Catalin.O

            @mrjj Seems the same, but, when building the payload, I'm already using a redirection like:

            md5sum <<< payload

            hskoglundH Offline
            hskoglundH Offline
            hskoglund
            wrote on last edited by
            #5

            @Catalin-O Just guessing, but because md5sum <<< payload is the same as

            md5sum <Enter>
            payload <Enter>
            

            i.e. it never checks for a file called payload or anything inside it, it only md5sums those 7 letters and a linefeed.

            Maybe md5sum payload is what you want, it sums the contents of the file.

            1 Reply Last reply
            3
            • mrjjM mrjj

              @Catalin.O

              But the good news it should give same result if presented with same input so
              So check you
              QByteArray d;
              against your payload.

              Catalin.OC Offline
              Catalin.OC Offline
              Catalin.O
              wrote on last edited by Catalin.O
              #6

              @mrjj said in QCryptographicHash::Md5 return a different value then md5sum linux command:

              against your payload.

              Thank you for support

              I managed to find the issue.

              The problem is the redirection that I made.

              md5sum <<< text

              @hskoglund

              you right

              1 Reply Last reply
              3

              • Login

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