read the file in chunks from filehash utility

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-03-12 00:16:43 +02:00
parent 255508bf4b
commit f1bbf0c42e

View file

@ -32,7 +32,7 @@ int main(int argc, char *argv[])
const QStringList args = app.arguments().mid(1);
if (args.size() != 2) {
qWarning() << "Usage: imgconv <md5|sha1|sha256|sha512|blake3> <filepath>";
qWarning() << "Usage: filehash <md5|sha1|sha256|sha512|blake3> <filepath>";
return 1;
}
@ -58,7 +58,9 @@ int main(int argc, char *argv[])
return 3;
}
const QByteArray hash = QCryptographicHash::hash(file.readAll(), algorithm).toHex();
QCryptographicHash cryptohash(algorithm);
cryptohash.addData(&file);
const QByteArray hash = cryptohash.result().toHex();
if (hash.isEmpty()) {
qWarning() << "Could not hash" << args.at(1);
return 4;