QCryptographicHash Class | Qt Core (original) (raw)

The QCryptographicHash class provides a way to generate cryptographic hashes. More...

Member Function Documentation

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<char> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<char> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpanstd::byte\ buffer, QByteArrayView data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpanstd::byte\ buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<uchar> buffer, QByteArrayView data, QCryptographicHash::Algorithm method)

[static noexcept, since 6.8] QByteArrayView QCryptographicHash::hashInto(QSpan<uchar> buffer, QSpan<const QByteArrayView> data, QCryptographicHash::Algorithm method)

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.

This function was introduced in Qt 6.8.

See also hash().

[explicit] QCryptographicHash::QCryptographicHash(QCryptographicHash::Algorithm method)

Constructs an object that can be used to create a cryptographic hash from data using method.

[noexcept, since 6.5] QCryptographicHash::QCryptographicHash(QCryptographicHash &&other)

Move-constructs a new QCryptographicHash from other.

Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

This function was introduced in Qt 6.5.

[noexcept] QCryptographicHash::~QCryptographicHash()

Destroys the object.

[noexcept] void QCryptographicHash::addData(QByteArrayView bytes)

Adds the characters in bytes to the cryptographic hash.

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.

[noexcept, since 6.5] QCryptographicHash::Algorithm QCryptographicHash::algorithm() const

Returns the algorithm used to generate the cryptographic hash.

This function was introduced in Qt 6.5.

[static] QByteArray QCryptographicHash::hash(QByteArrayView data, QCryptographicHash::Algorithm method)

Returns the hash of data using method.

See also hashInto().

[static] int QCryptographicHash::hashLength(QCryptographicHash::Algorithm method)

Returns the size of the output of the selected hash method in bytes.

[noexcept] void QCryptographicHash::reset()

Resets the object.

QByteArray QCryptographicHash::result() const

Returns the final hash value.

See also resultView() and QByteArray::toHex().

[noexcept, since 6.3] QByteArrayView QCryptographicHash::resultView() const

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.

This function was introduced in Qt 6.3.

See also result().

[static, since 6.5] bool QCryptographicHash::supportsAlgorithm(QCryptographicHash::Algorithm method)

Returns whether the selected algorithm method is supported and if result() will return a value when the method is used.

Note: OpenSSL will be responsible for providing this information when used as a provider, otherwise true will be returned as the non-OpenSSL implementation doesn't have any restrictions. We return false if we fail to query OpenSSL.

This function was introduced in Qt 6.5.

[noexcept, since 6.5] void QCryptographicHash::swap(QCryptographicHash &other)

Swaps this cryptographic hash with other. This operation is very fast and never fails.

This function was introduced in Qt 6.5.

[noexcept, since 6.5] QCryptographicHash &QCryptographicHash::operator=(QCryptographicHash &&other)

Move-assigns other to this QCryptographicHash instance.

Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

This function was introduced in Qt 6.5.