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.
  • C Offline
    C Offline
    Catalin.O
    wrote on 6 Dec 2017, 12:15 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 6 Dec 2017, 12:24 last edited by
      #2

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

      C 1 Reply Last reply 6 Dec 2017, 12:40
      2
      • M mrjj
        6 Dec 2017, 12:24

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

        C Offline
        C Offline
        Catalin.O
        wrote on 6 Dec 2017, 12:40 last edited by
        #3

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

        md5sum <<< payload

        M H 2 Replies Last reply 6 Dec 2017, 12:46
        0
        • C Catalin.O
          6 Dec 2017, 12:40

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

          md5sum <<< payload

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 6 Dec 2017, 12:46 last edited by mrjj 12 Jun 2017, 13:22
          #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.

          C 1 Reply Last reply 6 Dec 2017, 13:05
          0
          • C Catalin.O
            6 Dec 2017, 12:40

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

            md5sum <<< payload

            H Online
            H Online
            hskoglund
            wrote on 6 Dec 2017, 12:58 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
            • M mrjj
              6 Dec 2017, 12:46

              @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.

              C Offline
              C Offline
              Catalin.O
              wrote on 6 Dec 2017, 13:05 last edited by Catalin.O 12 Jun 2017, 13:08
              #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

              1/6

              6 Dec 2017, 12:15

              • Login

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