0

I need to link together sqlite database with unique external files. To ensure this, I made a table that stores a hash of file and encountered the following problem - QCryptographicHash::Md5 result is not the same as bash md5sum result. Can anyone says what i'm doing wrong? My code:

int main(int argc, char *argv[]) {

     QFile file(argv[0]);

     if (!file.open(QIODevice::ReadOnly)) return -1;
     QByteArray byteArray = file.readAll();

     QByteArray md5=QCryptographicHash::hash(byteArray,QCryptographicHash::Md5);

     qDebug()<<md5.toHex();

     return 0;
 }

Or maybe someone knows another solution of my problem? Using BLOB does not offer

aknew
  • 1,101
  • 7
  • 23
  • 1
    On my machine that code *appears* to gives the same result as md5sum. Does it always happen...such as with a file that just contains the letter 'A'? (I get `bf072e9119077b4e76437a93986787ef` for such a two byte file that's just an 'A' and a line feed) – HostileFork says dont trust SE May 02 '12 at 21:20
  • Ops, you are right, I gave a wrong link to the input. Thanks anyway – aknew May 02 '12 at 21:38

0 Answers0