use the http://doc.qt.io/qt-4.8/QCryptographicHash::addData(), instead QCryptographicHash::hash(),
#include <QCryptographicHash>
#include <QFile>
#include <QDebug>
int main()
{
QCryptographicHash crypto(QCryptographicHash::Md5);
QFile file("linuxmint-16-xfce-dvd-64bit.iso");
if ( !file.
open(QFile::ReadOnly) ){ qDebug() << "ERROR: cant read file";
}
qint64 size = 4 * 1024 * 1024; // segment of 4MB
int iter = 0;
while(!file.atEnd()){
crypto.addData(file.read(size));
++iter;
qDebug() << "iteration #" << iter
<< " data offset; " << size*iter << "(bytes)" ;
}
qDebug() << hash.toHex();
return true;
}
#include <QCryptographicHash>
#include <QFile>
#include <QDebug>
int main()
{
QCryptographicHash crypto(QCryptographicHash::Md5);
QFile file("linuxmint-16-xfce-dvd-64bit.iso");
if ( !file.open(QFile::ReadOnly) ){
qDebug() << "ERROR: cant read file";
}
qint64 size = 4 * 1024 * 1024; // segment of 4MB
int iter = 0;
while(!file.atEnd()){
crypto.addData(file.read(size));
++iter;
qDebug() << "iteration #" << iter
<< " data offset; " << size*iter << "(bytes)" ;
}
QByteArray hash = crypto.result();
qDebug() << hash.toHex();
return true;
}
To copy to clipboard, switch view to plain text mode
i test this minimal example, only replace the filepath
Bookmarks