Move FileKey::isHex() to Tools.

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

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

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

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;
}

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;
};