Krita Source Code Documentation
Loading...
Searching...
No Matches
KoMD5Generator.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2015 Stefano Bonicatti <smjert@gmail.com>
3
*
4
* SPDX-License-Identifier: LGPL-2.1-or-later
5
*/
6
#include "
KoMD5Generator.h
"
7
8
#include <QIODevice>
9
#include <QFile>
10
#include <QCryptographicHash>
11
12
QString
KoMD5Generator::generateHash
(
const
QByteArray &array)
13
{
14
QString result;
15
16
if
(!array.isEmpty()) {
17
QCryptographicHash md5(QCryptographicHash::Md5);
18
md5.addData(array);
19
result = md5.result().toHex();
20
}
21
22
return
result;
23
}
24
25
QString
KoMD5Generator::generateHash
(
const
QString &filename)
26
{
27
QString result;
28
29
QFile f(filename);
30
if
(f.exists() && f.open(QIODevice::ReadOnly)) {
31
QCryptographicHash md5(QCryptographicHash::Md5);
32
md5.addData(&f);
33
result = md5.result().toHex();
34
}
35
36
return
result;
37
}
38
39
QString
KoMD5Generator::generateHash
(QIODevice *device)
40
{
41
QString result;
42
43
QCryptographicHash md5(QCryptographicHash::Md5);
44
md5.addData(device);
45
result = md5.result().toHex();
46
47
return
result;
48
}
KoMD5Generator.h
KoMD5Generator::generateHash
static QString generateHash(const QString &filename)
generateHash reads the given file and generates a hex-encoded md5sum for the file.
Definition
KoMD5Generator.cpp:25
libs
resources
KoMD5Generator.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52