klipper: use Katie's hash algorithm for hashing

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-04-03 21:40:00 +03:00
parent d7838b9434
commit 7c2828b5cf
5 changed files with 23 additions and 16 deletions

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

View file

@ -16,12 +16,14 @@
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 )
{

View 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

View file

@ -63,12 +63,6 @@
//#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

View file

@ -21,24 +21,31 @@
#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;