Move FileKey::isHex() to Tools.

This commit is contained in:
Felix Geyer committed 2012-05-10 18:34:51 +02:00
1 parent ce0007acd2
commit 6eebd95de1
4 files changed
+14 -13

No files matched your search

+11
View File
@@ -103,4 +103,15 @@ QString imageReaderFilter()
return formatsStringList.join(" ");
}
bool isHex(const QByteArray& ba)
{
Q_FOREACH (char c, ba) {
if ( !( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ) ) {
return false;
}
}
return true;
}
} // namespace Tools
+1
View File
@@ -31,6 +31,7 @@ bool hasChild(const QObject* parent, const QObject* child);
bool readAllFromDevice(QIODevice* device, QByteArray& data);
QDateTime currentDateTimeUtc();
QString imageReaderFilter();
bool isHex(const QByteArray& ba);
} // namespace Tools
+2 -12
View File
@@ -20,6 +20,7 @@
#include <QtCore/QFile>
#include <QtCore/QXmlStreamReader>
#include "core/Tools.h"
#include "crypto/CryptoHash.h"
#include "crypto/Random.h"
@@ -233,7 +234,7 @@ bool FileKey::loadHex(QIODevice* device)
QByteArray data = device->readAll();
if (!isHex(data)) {
if (!Tools::isHex(data)) {
return false;
}
@@ -262,14 +263,3 @@ bool FileKey::loadHashed(QIODevice* device)
return true;
}
bool FileKey::isHex(const QByteArray& ba)
{
Q_FOREACH (char c, ba) {
if ( !( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ) ) {
return false;
}
}
return true;
}
-1
View File
@@ -42,7 +42,6 @@ private:
bool loadBinary(QIODevice* device);
bool loadHex(QIODevice* device);
bool loadHashed(QIODevice* device);
static bool isHex(const QByteArray& ba);
QByteArray m_key;
};