Replace sha2 with QCryptographicHash
This commit is contained in:
@@ -67,7 +67,6 @@ endif()
|
||||
link_directories(${TAGLIB_LIBRARY_DIRS})
|
||||
include_directories(${TAGLIB_INCLUDE_DIRS})
|
||||
|
||||
include_directories(${SHA2_INCLUDE_DIRS})
|
||||
include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS})
|
||||
include_directories(${QXT_INCLUDE_DIRS})
|
||||
|
||||
@@ -906,7 +905,6 @@ target_link_libraries(strawberry_lib
|
||||
libstrawberry-tagreader
|
||||
${GLIB_LIBRARIES}
|
||||
${GIO_LIBRARIES}
|
||||
${SHA2_LIBRARIES}
|
||||
${TAGLIB_LIBRARIES}
|
||||
${GOBJECT_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "utilities.h"
|
||||
#include "sha2.h"
|
||||
#include "timeconstants.h"
|
||||
#include "application.h"
|
||||
|
||||
@@ -431,7 +430,7 @@ QByteArray Hmac(const QByteArray &key, const QByteArray &data, HashFunction meth
|
||||
return QCryptographicHash::hash(outer_padding + QCryptographicHash::hash(inner_padding + data, QCryptographicHash::Sha1), QCryptographicHash::Sha1);
|
||||
}
|
||||
else { // Sha256_Algo, currently default
|
||||
return Sha256(outer_padding + Sha256(inner_padding + data));
|
||||
return QCryptographicHash::hash(outer_padding + QCryptographicHash::hash(inner_padding + data, QCryptographicHash::Sha256), QCryptographicHash::Sha256);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -448,27 +447,6 @@ QByteArray HmacSha1(const QByteArray &key, const QByteArray &data) {
|
||||
return Hmac(key, data, Sha1_Algo);
|
||||
}
|
||||
|
||||
QByteArray Sha256(const QByteArray &data) {
|
||||
|
||||
#ifndef USE_SYSTEM_SHA2
|
||||
using strawberry_sha2::SHA256_CTX;
|
||||
using strawberry_sha2::SHA256_Init;
|
||||
using strawberry_sha2::SHA256_Update;
|
||||
using strawberry_sha2::SHA256_Final;
|
||||
using strawberry_sha2::SHA256_DIGEST_LENGTH;
|
||||
#endif
|
||||
|
||||
SHA256_CTX context;
|
||||
SHA256_Init(&context);
|
||||
SHA256_Update(&context, reinterpret_cast<const quint8*>(data.constData()), data.length());
|
||||
|
||||
QByteArray ret(SHA256_DIGEST_LENGTH, '\0');
|
||||
SHA256_Final(reinterpret_cast<quint8*>(ret.data()), &context);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
// File must not be open and will be closed afterwards!
|
||||
QByteArray Sha1File(QFile &file) {
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ QByteArray Hmac(const QByteArray &key, const QByteArray &data, HashFunction algo
|
||||
QByteArray HmacMd5(const QByteArray &key, const QByteArray &data);
|
||||
QByteArray HmacSha256(const QByteArray &key, const QByteArray &data);
|
||||
QByteArray HmacSha1(const QByteArray &key, const QByteArray &data);
|
||||
QByteArray Sha256(const QByteArray &data);
|
||||
QByteArray Sha1File(QFile &file);
|
||||
QByteArray Sha1CoverHash(const QString &artist, const QString &album);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user