Krita Source Code Documentation
Loading...
Searching...
No Matches
KoMD5Generator Class Reference

#include <KoMD5Generator.h>

Static Public Member Functions

static QString generateHash (const QByteArray &array)
 generateHash calculates the md5sum of the given bytes
 
static QString generateHash (const QString &filename)
 generateHash reads the given file and generates a hex-encoded md5sum for the file.
 
static QString generateHash (QIODevice *device)
 generateHash calculates the md5sum of the given device
 

Detailed Description

Definition at line 16 of file KoMD5Generator.h.

Member Function Documentation

◆ generateHash() [1/3]

QString KoMD5Generator::generateHash ( const QByteArray & array)
static

generateHash calculates the md5sum of the given bytes

Parameters
QByteArraythe contents to be calculated
Returns
a hex-encoded string representation of the md5sum

Definition at line 12 of file KoMD5Generator.cpp.

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}

◆ generateHash() [2/3]

QString KoMD5Generator::generateHash ( const QString & filename)
static

generateHash reads the given file and generates a hex-encoded md5sum for the file.

Parameters
filenamethe file to open
Returns
a hex-encoded string representation of the md5sum

Definition at line 25 of file KoMD5Generator.cpp.

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}

◆ generateHash() [3/3]

QString KoMD5Generator::generateHash ( QIODevice * device)
static

generateHash calculates the md5sum of the given device

Parameters
QIODevice
Returns
a hex-encoded string representation of the md5sum

Definition at line 39 of file KoMD5Generator.cpp.

40{
41 QString result;
42
43 QCryptographicHash md5(QCryptographicHash::Md5);
44 md5.addData(device);
45 result = md5.result().toHex();
46
47 return result;
48}

The documentation for this class was generated from the following files: