QMessageAuthenticationCode¶
The
QMessageAuthenticationCode
class provides a way to generate hash-based message authentication codes. More…
Detailed Description¶
QMessageAuthenticationCode
supports all cryptographic hashes which are supported byQCryptographicHash
.To generate message authentication code, pass hash algorithm
Algorithm
to constructor, then set key and message bysetKey()
andaddData()
functions. Result can be acquired byresult()
function.QByteArray key = "key"; QByteArray message = "The quick brown fox jumps over the lazy dog"; ... QMessageAuthenticationCode code(QCryptographicHash::Sha1); code.setKey(key); code.addData(message); code.result().toHex(); // returns "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"Alternatively, this effect can be achieved by providing message, key and method to
hash()
method.QMessageAuthenticationCode::hash(message, key, QCryptographicHash::Sha1).toHex();See also
-
class
QMessageAuthenticationCode
(method[, key=QByteArray()])¶ - param method
Algorithm
- param key
Constructs an object that can be used to create a cryptographic hash from data using method
method
and keykey
.
-
PySide2.QtCore.QMessageAuthenticationCode.
addData
(device)¶ - Parameters
device –
QIODevice
- Return type
bool
Reads the data from the open
QIODevice
device
until it ends and adds it to message. Returnstrue
if reading was successful.Note
device
must be already opened.
-
PySide2.QtCore.QMessageAuthenticationCode.
addData
(data) - Parameters
data –
QByteArray
-
PySide2.QtCore.QMessageAuthenticationCode.
addData
(data, length) - Parameters
data – str
length –
int
Adds the first
length
chars ofdata
to the message.
-
static
PySide2.QtCore.QMessageAuthenticationCode.
hash
(message, key, method)¶ - Parameters
message –
QByteArray
key –
QByteArray
method –
Algorithm
- Return type
Returns the authentication code for the message
message
using the keykey
and the methodmethod
.
-
PySide2.QtCore.QMessageAuthenticationCode.
reset
()¶ Resets message data. Calling this method doesn’t affect the key.
-
PySide2.QtCore.QMessageAuthenticationCode.
result
()¶ - Return type
Returns the final authentication code.
See also
-
PySide2.QtCore.QMessageAuthenticationCode.
setKey
(key)¶ - Parameters
key –
QByteArray
Sets secret
key
. Calling this method automatically resets the object state.
© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.