Ok, I used this:
QCryptographicHash hash(QCryptographicHash::Md5);
char buf[2048];
int bytesRead;
qint64 overallBytesRead = 0;
while ((bytesRead = in.read(buf, 2048)) > 0) {
overallBytesRead += bytesRead;
hash.addData(buf, 2048);
}
in.close();
qDebug() << "overall bytes read:" << overallBytesRead;
qDebug() << hash.result().toHex();
}
else {
qDebug() << "Failed to open device!";
}
QCryptographicHash hash(QCryptographicHash::Md5);
QFile in("/dev/cdrom");
if (in.open(QIODevice::ReadOnly)) {
char buf[2048];
int bytesRead;
qint64 overallBytesRead = 0;
while ((bytesRead = in.read(buf, 2048)) > 0) {
overallBytesRead += bytesRead;
hash.addData(buf, 2048);
}
in.close();
qDebug() << "overall bytes read:" << overallBytesRead;
qDebug() << hash.result().toHex();
}
else {
qDebug() << "Failed to open device!";
}
To copy to clipboard, switch view to plain text mode
After completed, overallBytesRead is "8738865152", but the file size of image is "8738846720". He reads more bytes as on dvd is! I'm confused!
Bookmarks