#include <KDebug>
//TODO use mutable to make some methods const?
-// TODO: implement md4 support
+// TODO: implement sha256 and sha512 support
const QStringList VerifierPrivate::SUPPORTED = (QStringList() << "sha1" << "md5" << "md4");
+const QString VerifierPrivate::MD4 = QString("md4");
+const int VerifierPrivate::MD4LENGTH = 16;
const QString VerifierPrivate::MD5 = QString("md5");
const int VerifierPrivate::MD5LENGTH = 32;
const QString VerifierPrivate::SHA1 = QString("sha1");
pieceLength = fileSize - startOffset;
}
- if (type != MD5 && type != SHA1) {
+ if (type != MD4 && type != MD5 && type != SHA1) {
return QString();
}
}
QCryptographicHash *hash = 0;
- if (type == MD5) {
+ if (type == MD4) {
+ hash = new QCryptographicHash(QCryptographicHash::Md4);
+ } else if (type == MD5) {
hash = new QCryptographicHash(QCryptographicHash::Md5);
} else if (type == SHA1) {
hash = new QCryptographicHash(QCryptographicHash::Sha1);
QStringList Verifier::supportedVerficationTypes()
{
QStringList supported;
- if (!supported.contains(VerifierPrivate::MD5))
+ if (!supported.contains(VerifierPrivate::MD4))
{
- supported << VerifierPrivate::MD5 << VerifierPrivate::SHA1;
+ supported << VerifierPrivate::MD4 << VerifierPrivate::MD5 << VerifierPrivate::SHA1;
}
return supported;
int Verifier::diggestLength(const QString &type)
{
- if (type == VerifierPrivate::MD5) {
+ if (type == VerifierPrivate::MD4) {
+ return VerifierPrivate::MD4LENGTH;
+ } else if (type == VerifierPrivate::MD5) {
return VerifierPrivate::MD5LENGTH;
} else if (type == VerifierPrivate::SHA1) {
return VerifierPrivate::SHA1LENGTH;
return QString();
}
- if (type == VerifierPrivate::MD5) {
+ if (type == VerifierPrivate::MD4) {
+ QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md4);
+ file.close();
+ return hash.toHex();
+ } else if (type == VerifierPrivate::MD5) {
QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5);
file.close();
return hash.toHex();
<group name="ChecksumSearch">
<entry name="SearchStrings" type="StringList">
<label>List of the available search engines</label>
- <default>.md5,MD5SUMS,.sha1,SHA1SUMS,-CHECKSUM</default>
+ <default>.md4,MD4SUMS,.md5,MD5SUMS,.sha1,SHA1SUMS,-CHECKSUM</default>
</entry>
<entry name="UrlChangeModeList" type="IntList">
<label>List of the available search engine URLs</label>
- <default>0,1,0,1,2</default>
+ <default>0,1,0,1,0,1,2</default>
</entry>
<entry name="ChecksumTypeList" type="StringList">
<label>List of the available search engine URLs</label>
- <default>md5,md5,sha1,sha1,</default>
+ <default>md4,md4,md5,md5,sha1,sha1,</default>
</entry>
</group>
</kcfg>