summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-05-12 16:52:19 +0200
committerArno <am@disconnect.de>2010-05-12 16:52:19 +0200
commitce5cb5bc57ae95ca920b0a8b4715a201a491d897 (patch)
tree2e6a2b294b8b9427e36705484201eea6b85502ce
parentff2fd5022cc1bda8a3ec8271604e9d7eaeee53de (diff)
downloadSheMov-ce5cb5bc57ae95ca920b0a8b4715a201a491d897.tar.gz
SheMov-ce5cb5bc57ae95ca920b0a8b4715a201a491d897.tar.bz2
SheMov-ce5cb5bc57ae95ca920b0a8b4715a201a491d897.zip
Got rid of crypto++ dependency
Replaced calls to crypto++ with QCryptographicHash
-rw-r--r--helper.cpp45
-rw-r--r--shemov.pro2
2 files changed, 22 insertions, 25 deletions
diff --git a/helper.cpp b/helper.cpp
index e30b299..1b8640b 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -10,12 +10,7 @@
#include <QFileInfo>
#include <QFile>
#include <QSettings>
-
-#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
-#include <md5.h>
-#include <files.h>
-#include <filters.h>
-#include <hex.h>
+#include <QCryptographicHash>
#include "helper.h"
@@ -41,8 +36,8 @@ namespace Helper {
retval = "video/";
}
}
- return retval;
}
+ return retval;
}
const QString md5Sum(const QString &path){
@@ -51,28 +46,32 @@ namespace Helper {
return QString();
}
- using namespace CryptoPP;
- Weak::MD5 hash;
- std::string res;
QString retval;
+ QCryptographicHash h(QCryptographicHash::Md5);
+ QFile file(path);
+ file.open(QIODevice::ReadOnly);
+ qint64 read = 0;
if(info.size() < (5 * 1024 * 1024)){
- FileSource f(qPrintable(path), true, new HashFilter(hash, new HexEncoder(new StringSink(res))));
- retval = QString::fromStdString(res).toLower();
+ QByteArray data(4096, '\0');
+ do {
+ read = file.read(data.data(), 4096);
+ h.addData(data.data(), read);
+ } while (read == 4096);
+ QByteArray res = h.result();
+ retval = res.toHex().toLower();
}else{
- QFile file(path);
- file.open(QIODevice::ReadOnly);
+ QByteArray data(512, '\0');
int offset = info.size() / 3;
file.seek(offset);
int numBytes = 512 * 1024;
- char *data = new char[numBytes];
- int read = file.read(data, numBytes);
- if(read != numBytes){
- delete [] data;
- return QString();
- }
- StringSource s((byte*)data, numBytes, true, new HashFilter(hash, new HexEncoder(new StringSink(res))));
- retval = QString::fromStdString(res).toLower();
- delete [] data;
+ int readBytes = 0;
+ do {
+ read = file.read(data.data(), 512);
+ readBytes += read;
+ h.addData(data.data(), read);
+ } while(readBytes < numBytes);
+ QByteArray res = h.result();
+ retval = res.toHex().toLower();
}
return retval;
}
diff --git a/shemov.pro b/shemov.pro
index c4f7449..1201dbd 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -78,6 +78,4 @@ HEADERS = listitem.h \
graphbarwidget.h \
programconfigurator.h
LIBS += -lmagic
-LIBS += -lcryptopp
-INCLUDEPATH += /usr/include/cryptopp
RESOURCES = shemov.qrc