Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Integrity data fails on the recompile

    General and Desktop
    2
    6
    890
    Loading More Posts
    • 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.
    • Cobra91151
      Cobra91151 last edited by

      Hi! I have a program that encrypt the password, stores it in the registry and displays it later.

      I use SimpleCrypt to encrypt and decrypt the password. It works well, but the strange issue is when recompile the application. Then, it displays the empty string. I have checked:

      bool integrityOk(true);
          if (flags.testFlag(CryptoFlagChecksum)) {
              if (ba.length() < 2) {
                  m_lastError = ErrorIntegrityFailed;
                  return QByteArray();
              }
              quint16 storedChecksum;
              {
                  QDataStream s(&ba, QIODevice::ReadOnly);
                  s >> storedChecksum;
              }
              ba = ba.mid(2);
              quint16 checksum = qChecksum(ba.constData(), ba.length());
      
              qDebug() << checksum;
              qDebug() << storedChecksum;
      
              integrityOk = (checksum == storedChecksum);
      
              qDebug() << integrityOk; // false
          }
      
          if (!integrityOk) {
              qDebug() << "Test";
              m_lastError = ErrorIntegrityFailed;
              return QByteArray();
          }
      

      Integrity check fails and it return the empty string. Any ideas? Thanks.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Check your seeding, also, you should fix the version of the QDataStream you are using otherwise you might hit compatibility problem using different version of Qt.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Cobra91151 1 Reply Last reply Reply Quote 0
        • Cobra91151
          Cobra91151 @SGaist last edited by

          @SGaist

          I have set the version.

          Code:

          QDataStream s(&ba, QIODevice::ReadOnly);
          s.setVersion(QDataStream::Qt_5_7);
          

          But the same issue exists. What do you mean by: Check your seeding?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Check how you are initialising your SimpleCrypt object.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Cobra91151 1 Reply Last reply Reply Quote 1
            • Cobra91151
              Cobra91151 @SGaist last edited by

              @SGaist

              I have fixed the problem. The problem was with the wrong key implementation. Thank you.

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                You're welcome !

                Out of curiosity, what do you mean by "wrong key implementation" ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post