OSDN Git Service

read the file in chunks from filehash utility
authorIvailo Monev <xakepa10@gmail.com>
Fri, 11 Mar 2022 22:16:43 +0000 (00:16 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 11 Mar 2022 22:16:43 +0000 (00:16 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
util/filehash/main.cpp

index 2268112..01743ca 100644 (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;