OSDN Git Service

klipper: use Katie's hash algorithm for hashing
authorIvailo Monev <xakepa10@gmail.com>
Sun, 3 Apr 2022 18:40:00 +0000 (21:40 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 3 Apr 2022 18:40:00 +0000 (21:40 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
klipper/historyimageitem.cpp
klipper/historystringitem.cpp
klipper/historyurlitem.cpp
klipper/klipper.cpp
klipper/klipper.h

index b6247bd..fd34d94 100644 (file)
@@ -16,6 +16,8 @@
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
 */
+
+#include "klipper.h"
 #include "historyimageitem.h"
 
 #include <QtCore/QMimeData>
@@ -28,7 +30,7 @@ namespace {
         QByteArray buffer;
         QDataStream out(&buffer, QIODevice::WriteOnly);
         out << data;
-        return QCryptographicHash::hash(buffer, QCryptographicHash::Sha1);
+        return QCryptographicHash::hash(buffer, KlipperHashAlhorithm);
     }
 
 }
index 4b4ab7f..137c248 100644 (file)
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
 */
+
+#include "klipper.h"
 #include "historystringitem.h"
 
 #include <QCryptographicHash>
 
 HistoryStringItem::HistoryStringItem( const QString& data )
-    : HistoryItem(QCryptographicHash::hash(data.toUtf8(), QCryptographicHash::Sha1))
+    : HistoryItem(QCryptographicHash::hash(data.toUtf8(), KlipperHashAlhorithm))
     , m_data( data )
 {
 
index 880d06e..e4f1d61 100644 (file)
@@ -16,6 +16,8 @@
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
 */
+
+#include "klipper.h"
 #include "historyurlitem.h"
 
 #include <QtCore/QMimeData>
@@ -23,7 +25,7 @@
 
 namespace {
     QByteArray compute_uuid(const KUrl::List& _urls, KUrl::MetaDataMap _metaData, bool _cut ) {
-        QCryptographicHash hash(QCryptographicHash::Sha1);
+        QCryptographicHash hash(KlipperHashAlhorithm);
         foreach(const KUrl& url, _urls) {
             hash.addData(url.toEncoded());
             hash.addData("\0", 1); // Use binary zero as that is not a valid path character
index ae2356e..ee76fb0 100644 (file)
 
 //#define NOISY_KLIPPER
 
-#if QT_VERSION >= 0x041200
-static const QCryptographicHash::Algorithm KlipperHashAlhorithm = QCryptographicHash::KAT;
-#else
-static const QCryptographicHash::Algorithm KlipperHashAlhorithm = QCryptographicHash::Sha1;
-#endif
-
 namespace {
     /**
      * Use this when manipulating the clipboard
index 3f228d6..2d54f62 100644 (file)
 #ifndef KLIPPER_H
 #define KLIPPER_H
 
-#include <QtCore/qdatetime.h>
-#include <QtCore/QTimer>
-#include <QtGui/QClipboard>
+#include <QTime>
+#include <QAction>
+#include <QMenu>
+#include <QMimeData>
+#include <QDateTime>
+#include <QTimer>
+#include <QClipboard>
+#include <QCryptographicHash>
 
 #include <KGlobal>
 
 #include "urlgrabber.h"
 
+#if QT_VERSION >= 0x041200
+static const QCryptographicHash::Algorithm KlipperHashAlhorithm = QCryptographicHash::KAT;
+#else
+static const QCryptographicHash::Algorithm KlipperHashAlhorithm = QCryptographicHash::Sha1;
+#endif
+
 class KAction;
 class KToggleAction;
 class KAboutData;
 class KActionCollection;
 class URLGrabber;
-#include <QTime>
 class History;
-#include <QAction>
-#include <QMenu>
-#include <QMimeData>
 class HistoryItem;
 class KlipperSessionManager;