-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7cdd6f
commit 8ca1c89
Showing
8 changed files
with
55 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "utilities.h" | ||
|
||
#include<QString> | ||
#include<QFile> | ||
#include<QCryptographicHash> | ||
#include<QDebug> | ||
|
||
QByteArray getHash(QString fileName) | ||
{ | ||
QString hashString; | ||
QFile file(fileName); | ||
QByteArray hashArray; | ||
QCryptographicHash *sha1Hash; | ||
|
||
//Attempt to open the file | ||
if(!file.open(QFile::ReadOnly)) | ||
{ | ||
qDebug() << "Unable to read file:" << fileName << ". Error:" << file.errorString() << "\n"; | ||
} | ||
else | ||
{ | ||
//Load the file's data to process | ||
QByteArray fileContents = file.readAll(); | ||
|
||
hashArray = sha1Hash->hash(fileContents, QCryptographicHash::Sha1); | ||
} | ||
|
||
//clean up the file since we are done with it | ||
file.flush(); | ||
file.close(); | ||
file.deleteLater(); | ||
|
||
//return the checksum in hexidecimal format since that is what the manifest requires | ||
return hashArray.toHex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef UTILITIES_H | ||
#define UTILITIES_H | ||
|
||
#include <QByteArray> | ||
|
||
QByteArray getHash(QString); | ||
|
||
#endif // UTILITIES_H |