KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
CryptoUtil Class Reference

CryptoUtil. More...

#include <cryptoutil.h>

Static Public Member Functions

static QByteArray fileMd5 (const QString &filename)
 Compute the MD5 hash of a file's contents.
 
static QString fileMd5String (const QString &filename)
 Compute the MD5 hash of a file's contents as a hex string.
 
static QByteArray md5 (const QByteArray &of)
 Compute the MD5 hash of a byte array.
 
static uint64_t md5UInt64 (const QByteArray &of)
 Compute the MD5 hash of a byte array as a 64-bit unsigned integer.
 
static QString md5String (const QString &of)
 Compute the MD5 hash of a string as a hex string.
 
static QString md5String (const QByteArray &of)
 Compute the MD5 hash of a byte array as a hex string.
 
static QString md5String (const QStringList &of)
 Compute the MD5 hash of a joined string list as a hex string.
 
static QByteArray md5 (const QStringList &of)
 Compute the MD5 hash of a string list as raw bytes.
 
static QByteArray fileSha256 (const QString &filename)
 Compute the SHA-256 hash of a file's contents.
 
static QString fileSha256String (const QString &filename)
 Compute the SHA-256 hash of a file's contents as a hex string.
 
static QByteArray sha256 (const QByteArray &of)
 Compute the SHA-256 hash of a byte array.
 
static QString sha256String (const QString &of)
 Compute the SHA-256 hash of a string as a hex string.
 
static QString sha256String (const QByteArray &of)
 Compute the SHA-256 hash of a byte array as a hex string.
 
static QString sha256String (const QStringList &of)
 Compute the SHA-256 hash of a joined string list as a hex string.
 
static QByteArray sha256 (const QStringList &of)
 Compute the SHA-256 hash of a string list as raw bytes.
 

Detailed Description

CryptoUtil.

Some static helper methods for MD5 hashes (to and from strings).

It is basically a front-end for QCryptographicHash functions.

Stephen Punak, February 17 2021

Static helper methods for computing MD5 hashes as byte arrays or hex strings.

Definition at line 21 of file cryptoutil.h.

Member Function Documentation

◆ fileMd5()

static QByteArray CryptoUtil::fileMd5 ( const QString &  filename)
static

Compute the MD5 hash of a file's contents.

Parameters
filenamePath to the file
Returns
Raw MD5 hash bytes, or empty array on error

◆ fileMd5String()

static QString CryptoUtil::fileMd5String ( const QString &  filename)
static

Compute the MD5 hash of a file's contents as a hex string.

Parameters
filenamePath to the file
Returns
Hex-encoded MD5 string, or empty string on error

◆ fileSha256()

static QByteArray CryptoUtil::fileSha256 ( const QString &  filename)
static

Compute the SHA-256 hash of a file's contents.

Parameters
filenamePath to the file
Returns
Raw SHA-256 hash bytes, or empty array on error

◆ fileSha256String()

static QString CryptoUtil::fileSha256String ( const QString &  filename)
static

Compute the SHA-256 hash of a file's contents as a hex string.

Parameters
filenamePath to the file
Returns
Hex-encoded SHA-256 string, or empty string on error

◆ md5() [1/2]

static QByteArray CryptoUtil::md5 ( const QByteArray &  of)
static

Compute the MD5 hash of a byte array.

Parameters
ofInput data
Returns
Raw MD5 hash bytes

◆ md5() [2/2]

static QByteArray CryptoUtil::md5 ( const QStringList &  of)
static

Compute the MD5 hash of a string list as raw bytes.

Parameters
ofList of strings to hash (concatenated)
Returns
Raw MD5 hash bytes

◆ md5String() [1/3]

static QString CryptoUtil::md5String ( const QByteArray &  of)
static

Compute the MD5 hash of a byte array as a hex string.

Parameters
ofInput data
Returns
Hex-encoded MD5 string

◆ md5String() [2/3]

static QString CryptoUtil::md5String ( const QString &  of)
static

Compute the MD5 hash of a string as a hex string.

Parameters
ofInput string
Returns
Hex-encoded MD5 string

◆ md5String() [3/3]

static QString CryptoUtil::md5String ( const QStringList &  of)
static

Compute the MD5 hash of a joined string list as a hex string.

Parameters
ofList of strings to hash (concatenated)
Returns
Hex-encoded MD5 string

◆ md5UInt64()

static uint64_t CryptoUtil::md5UInt64 ( const QByteArray &  of)
static

Compute the MD5 hash of a byte array as a 64-bit unsigned integer.

Parameters
ofInput data
Returns
First 8 bytes of the MD5 hash interpreted as uint64_t

◆ sha256() [1/2]

static QByteArray CryptoUtil::sha256 ( const QByteArray &  of)
static

Compute the SHA-256 hash of a byte array.

Parameters
ofInput data
Returns
Raw SHA-256 hash bytes

◆ sha256() [2/2]

static QByteArray CryptoUtil::sha256 ( const QStringList &  of)
static

Compute the SHA-256 hash of a string list as raw bytes.

Parameters
ofList of strings to hash (concatenated)
Returns
Raw SHA-256 hash bytes

◆ sha256String() [1/3]

static QString CryptoUtil::sha256String ( const QByteArray &  of)
static

Compute the SHA-256 hash of a byte array as a hex string.

Parameters
ofInput data
Returns
Hex-encoded SHA-256 string

◆ sha256String() [2/3]

static QString CryptoUtil::sha256String ( const QString &  of)
static

Compute the SHA-256 hash of a string as a hex string.

Parameters
ofInput string
Returns
Hex-encoded SHA-256 string

◆ sha256String() [3/3]

static QString CryptoUtil::sha256String ( const QStringList &  of)
static

Compute the SHA-256 hash of a joined string list as a hex string.

Parameters
ofList of strings to hash (concatenated)
Returns
Hex-encoded SHA-256 string

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