![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qcryptographichash.h>
Public Types | |
enum | Algorithm { Md4 , Md5 , Sha1 = 2 , Sha224 , Sha256 , Sha384 , Sha512 , Keccak_224 = 7 , Keccak_256 , Keccak_384 , Keccak_512 , RealSha3_224 = 11 , RealSha3_256 , RealSha3_384 , RealSha3_512 , Sha3_224 = RealSha3_224 , Sha3_256 = RealSha3_256 , Sha3_384 = RealSha3_384 , Sha3_512 = RealSha3_512 , Blake2b_160 = 15 , Blake2b_256 , Blake2b_384 , Blake2b_512 , Blake2s_128 , Blake2s_160 , Blake2s_224 , Blake2s_256 , NumAlgorithms } |
Public Member Functions | |
QCryptographicHash (Algorithm method) | |
Constructs an object that can be used to create a cryptographic hash from data using method. | |
QCryptographicHash (QCryptographicHash &&other) noexcept | |
Move-constructs a new QCryptographicHash from other. | |
~QCryptographicHash () | |
Destroys the object. | |
void | swap (QCryptographicHash &other) noexcept |
\memberswap{cryptographic hash} | |
void | reset () noexcept |
Resets the object. | |
Algorithm | algorithm () const noexcept |
Returns the algorithm used to generate the cryptographic hash. | |
void | addData (QByteArrayView data) noexcept |
Adds the characters in bytes to the cryptographic hash. | |
bool | addData (QIODevice *device) |
Reads the data from the open QIODevice device until it ends and hashes it. | |
QByteArray | result () const |
Returns the final hash value. | |
QByteArrayView | resultView () const noexcept |
Static Public Member Functions | |
static QByteArray | hash (QByteArrayView data, Algorithm method) |
Returns the hash of data using method. | |
static QByteArrayView | hashInto (QSpan< char > buffer, QByteArrayView data, Algorithm method) noexcept |
static QByteArrayView | hashInto (QSpan< uchar > buffer, QByteArrayView data, Algorithm method) noexcept |
static QByteArrayView | hashInto (QSpan< std::byte > buffer, QByteArrayView data, Algorithm method) noexcept |
Returns the hash of data using method, using buffer to store the result. | |
static QByteArrayView | hashInto (QSpan< char > buffer, QSpan< const QByteArrayView > data, Algorithm method) noexcept |
static QByteArrayView | hashInto (QSpan< uchar > buffer, QSpan< const QByteArrayView > data, Algorithm method) noexcept |
static QByteArrayView | hashInto (QSpan< std::byte > buffer, QSpan< const QByteArrayView > data, Algorithm method) noexcept |
static int | hashLength (Algorithm method) |
Returns the size of the output of the selected hash method in bytes. | |
static bool | supportsAlgorithm (Algorithm method) |
Returns whether the selected algorithm method is supported and if result() will return a value when the method is used. | |
\inmodule QtCore
The QCryptographicHash class provides a way to generate cryptographic hashes.
\reentrant
QCryptographicHash can be used to generate cryptographic hashes of binary or text data.
Refer to the documentation of the \l QCryptographicHash::Algorithm enum for a list of the supported algorithms.
Definition at line 19 of file qcryptographichash.h.
{Keccak_} enumerators. Alternatively, if source compatibility is required, define the macro QT_SHA3_KECCAK_COMPAT
.\value Md4 Generate an MD4 hash sum \value Md5 Generate an MD5 hash sum \value Sha1 Generate an SHA-1 hash sum \value Sha224 Generate an SHA-224 hash sum (SHA-2). Introduced in Qt 5.0 \value Sha256 Generate an SHA-256 hash sum (SHA-2). Introduced in Qt 5.0 \value Sha384 Generate an SHA-384 hash sum (SHA-2). Introduced in Qt 5.0 \value Sha512 Generate an SHA-512 hash sum (SHA-2). Introduced in Qt 5.0 \value Sha3_224 Generate an SHA3-224 hash sum. Introduced in Qt 5.1 \value Sha3_256 Generate an SHA3-256 hash sum. Introduced in Qt 5.1 \value Sha3_384 Generate an SHA3-384 hash sum. Introduced in Qt 5.1 \value Sha3_512 Generate an SHA3-512 hash sum. Introduced in Qt 5.1 \value Keccak_224 Generate a Keccak-224 hash sum. Introduced in Qt 5.9.2 \value Keccak_256 Generate a Keccak-256 hash sum. Introduced in Qt 5.9.2 \value Keccak_384 Generate a Keccak-384 hash sum. Introduced in Qt 5.9.2 \value Keccak_512 Generate a Keccak-512 hash sum. Introduced in Qt 5.9.2 \value Blake2b_160 Generate a BLAKE2b-160 hash sum. Introduced in Qt 6.0 \value Blake2b_256 Generate a BLAKE2b-256 hash sum. Introduced in Qt 6.0 \value Blake2b_384 Generate a BLAKE2b-384 hash sum. Introduced in Qt 6.0 \value Blake2b_512 Generate a BLAKE2b-512 hash sum. Introduced in Qt 6.0 \value Blake2s_128 Generate a BLAKE2s-128 hash sum. Introduced in Qt 6.0 \value Blake2s_160 Generate a BLAKE2s-160 hash sum. Introduced in Qt 6.0 \value Blake2s_224 Generate a BLAKE2s-224 hash sum. Introduced in Qt 6.0 \value Blake2s_256 Generate a BLAKE2s-256 hash sum. Introduced in Qt 6.0 \omitvalue RealSha3_224 \omitvalue RealSha3_256 \omitvalue RealSha3_384 \omitvalue RealSha3_512 \omitvalue NumAlgorithms
Definition at line 23 of file qcryptographichash.h.
|
explicit |
Constructs an object that can be used to create a cryptographic hash from data using method.
Definition at line 432 of file qcryptographichash.cpp.
|
inlinenoexcept |
Move-constructs a new QCryptographicHash from other.
Definition at line 69 of file qcryptographichash.h.
QCryptographicHash::~QCryptographicHash | ( | ) |
Destroys the object.
Definition at line 452 of file qcryptographichash.cpp.
|
noexcept |
Adds the characters in bytes to the cryptographic hash.
Definition at line 761 of file qcryptographichash.cpp.
bool QCryptographicHash::addData | ( | QIODevice * | device | ) |
Reads the data from the open QIODevice device until it ends and hashes it.
Returns true
if reading was successful.
Definition at line 880 of file qcryptographichash.cpp.
|
nodiscardnoexcept |
Returns the algorithm used to generate the cryptographic hash.
Definition at line 488 of file qcryptographichash.cpp.
|
static |
Returns the hash of data using method.
Definition at line 1101 of file qcryptographichash.cpp.
|
inlinestaticnoexcept |
Definition at line 96 of file qcryptographichash.h.
|
inlinestaticnoexcept |
Definition at line 102 of file qcryptographichash.h.
|
inlinestaticnoexcept |
Returns the hash of data using method, using buffer to store the result.
If data is a span, adds all the byte array views to the hash, in the order given.
The return value will be a sub-span of buffer, unless buffer is of insufficient size, in which case a null QByteArrayView is returned.
Definition at line 100 of file qcryptographichash.h.
|
staticnoexcept |
Definition at line 1127 of file qcryptographichash.cpp.
|
inlinestaticnoexcept |
Definition at line 98 of file qcryptographichash.h.
|
inlinestaticnoexcept |
Definition at line 104 of file qcryptographichash.h.
|
static |
Returns the size of the output of the selected hash method in bytes.
Definition at line 1150 of file qcryptographichash.cpp.
|
noexcept |
Resets the object.
Definition at line 478 of file qcryptographichash.cpp.
QByteArray QCryptographicHash::result | ( | ) | const |
Returns the final hash value.
Definition at line 908 of file qcryptographichash.cpp.
|
noexcept |
Returns the final hash value.
Note that the returned view remains valid only as long as the QCryptographicHash object is not modified by other means.
Definition at line 923 of file qcryptographichash.cpp.
|
static |
Returns whether the selected algorithm method is supported and if result() will return a value when the method is used.
true
will be returned as the non-OpenSSL implementation doesn't have any restrictions. We return false
if we fail to query OpenSSL.Definition at line 1168 of file qcryptographichash.cpp.
|
inlinenoexcept |