Integrity data fails on the recompile



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


  • Lifetime Qt Champion

    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.



  • @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?


  • Lifetime Qt Champion

    Check how you are initialising your SimpleCrypt object.



  • @SGaist

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


  • Lifetime Qt Champion

    You're welcome !

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


Log in to reply
 

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