![]() |
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 <qmessageauthenticationcode.h>
Public Member Functions | |
QMessageAuthenticationCode (QCryptographicHash::Algorithm method, QByteArrayView key={}) | |
QMessageAuthenticationCode (QMessageAuthenticationCode &&other) noexcept | |
Move-constructs a new QMessageAuthenticationCode from other. | |
~QMessageAuthenticationCode () | |
Destroys the object. | |
void | swap (QMessageAuthenticationCode &other) noexcept |
\memberswap{message authentication code} | |
void | reset () noexcept |
Resets message data. | |
void | setKey (QByteArrayView key) noexcept |
Sets secret key. | |
void | addData (const char *data, qsizetype length) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the first length chars of data to the message. | |
void | addData (QByteArrayView data) noexcept |
Adds data to the message. | |
bool | addData (QIODevice *device) |
Reads the data from the open QIODevice device until it ends and adds it to message. | |
QByteArrayView | resultView () const noexcept |
QByteArray | result () const |
Returns the final authentication code. | |
\inmodule QtCore
The QMessageAuthenticationCode class provides a way to generate hash-based message authentication codes.
\reentrant
Use the QMessageAuthenticationCode class to generate hash-based message authentication codes (HMACs). The class supports all cryptographic hash algorithms from \l QCryptographicHash (see also \l{QCryptographicHash::Algorithm}).
To generate a message authentication code, pass a suitable hash algorithm and secret key to the constructor. Then process the message data by calling \l addData() one or more times. After the full message has been processed, get the final authentication code via the \l result() function:
\dots
For simple cases like above, you can also use the static \l hash() function:
Definition at line 16 of file qmessageauthenticationcode.h.
|
explicit |
Constructs an object that can be used to create a cryptographic hash from data using method \a method and key \a key.
! [qba-to-qbav-6.6]
{QByteArray{~~~}} to make the cast explicit. This is backwards-compatible with old Qt versions. ! [qba-to-qbav-6.6] Definition at line 1441 of file qcryptographichash.cpp.
|
inlinenoexcept |
Move-constructs a new QMessageAuthenticationCode from other.
Definition at line 26 of file qmessageauthenticationcode.h.
QMessageAuthenticationCode::~QMessageAuthenticationCode | ( | ) |
Destroys the object.
Definition at line 1451 of file qcryptographichash.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Adds the first length chars of data to the message.
Definition at line 1537 of file qcryptographichash.cpp.
|
noexcept |
Adds data to the message.
{qba-to-qbav-6.6}
Definition at line 1549 of file qcryptographichash.cpp.
bool QMessageAuthenticationCode::addData | ( | QIODevice * | device | ) |
Reads the data from the open QIODevice device until it ends and adds it to message.
Returns true
if reading was successful.
Definition at line 1560 of file qcryptographichash.cpp.
|
static |
Returns the authentication code for the message message using the key key and the method method.
{qba-to-qbav-6.6}
Definition at line 1618 of file qcryptographichash.cpp.
|
inlinestaticnoexcept |
Definition at line 59 of file qmessageauthenticationcode.h.
|
inlinestaticnoexcept |
Definition at line 71 of file qmessageauthenticationcode.h.
|
inlinestaticnoexcept |
Returns the authentication code for the message (message or, for the QSpan overloads, the concatenation of messageParts) using the key key and the method method.
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 67 of file qmessageauthenticationcode.h.
|
staticnoexcept |
Definition at line 1645 of file qcryptographichash.cpp.
|
inlinestaticnoexcept |
Definition at line 63 of file qmessageauthenticationcode.h.
|
inlinestaticnoexcept |
Definition at line 75 of file qmessageauthenticationcode.h.
|
noexcept |
Resets message data.
Calling this function doesn't affect the key.
Definition at line 1489 of file qcryptographichash.cpp.
QByteArray QMessageAuthenticationCode::result | ( | ) | const |
Returns the final authentication code.
Definition at line 1586 of file qcryptographichash.cpp.
|
noexcept |
Returns the final hash value.
Note that the returned view remains valid only as long as the QMessageAuthenticationCode object is not modified by other means.
Definition at line 1575 of file qcryptographichash.cpp.
|
noexcept |
Sets secret key.
Calling this function automatically resets the object state.
For optimal performance, call this function only to change the active key, not to set an initial key, as in
Prefer to pass initial keys as the constructor argument:
You can use std::optional to delay construction of a QMessageAuthenticationCode until you know the key:
{qba-to-qbav-6.6}
Definition at line 1527 of file qcryptographichash.cpp.
|
inlinenoexcept |
\memberswap{message authentication code}
Definition at line 31 of file qmessageauthenticationcode.h.