Struct qt_core::QMessageAuthenticationCode
source · #[repr(C)]pub struct QMessageAuthenticationCode { /* private fields */ }
Expand description
The QMessageAuthenticationCode class provides a way to generate hash-based message authentication codes.
C++ class: QMessageAuthenticationCode
.
The QMessageAuthenticationCode class provides a way to generate hash-based message authentication codes.
QMessageAuthenticationCode supports all cryptographic hashes which are supported by QCryptographicHash.
To generate message authentication code, pass hash algorithm QCryptographicHash::Algorithm to constructor, then set key and message by setKey() and addData() functions. Result can be acquired by result() 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();
Implementations§
source§impl QMessageAuthenticationCode
impl QMessageAuthenticationCode
sourcepub unsafe fn add_data_char_int(&self, data: *const c_char, length: c_int)
pub unsafe fn add_data_char_int(&self, data: *const c_char, length: c_int)
Adds the first length chars of data to the message.
Calls C++ function: void QMessageAuthenticationCode::addData(const char* data, int length)
.
Adds the first length chars of data to the message.
sourcepub unsafe fn add_data_q_byte_array(&self, data: impl CastInto<Ref<QByteArray>>)
pub unsafe fn add_data_q_byte_array(&self, data: impl CastInto<Ref<QByteArray>>)
sourcepub unsafe fn add_data_q_io_device(
&self,
device: impl CastInto<Ptr<QIODevice>>
) -> bool
pub unsafe fn add_data_q_io_device( &self, device: impl CastInto<Ptr<QIODevice>> ) -> bool
Reads the data from the open QIODevice device until it ends and adds it to message. Returns true
if reading was successful.
Calls C++ function: 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.
Note: device must be already opened.
sourcepub unsafe fn hash(
message: impl CastInto<Ref<QByteArray>>,
key: impl CastInto<Ref<QByteArray>>,
method: Algorithm
) -> CppBox<QByteArray>
pub unsafe fn hash( message: impl CastInto<Ref<QByteArray>>, key: impl CastInto<Ref<QByteArray>>, method: Algorithm ) -> CppBox<QByteArray>
Returns the authentication code for the message message using the key key and the method method.
Calls C++ function: static QByteArray QMessageAuthenticationCode::hash(const QByteArray& message, const QByteArray& key, QCryptographicHash::Algorithm method)
.
Returns the authentication code for the message message using the key key and the method method.
sourcepub unsafe fn new_2a(
method: Algorithm,
key: impl CastInto<Ref<QByteArray>>
) -> CppBox<QMessageAuthenticationCode>
pub unsafe fn new_2a( method: Algorithm, key: impl CastInto<Ref<QByteArray>> ) -> CppBox<QMessageAuthenticationCode>
Constructs an object that can be used to create a cryptographic hash from data using method method and key key.
Calls C++ function: [constructor] void QMessageAuthenticationCode::QMessageAuthenticationCode(QCryptographicHash::Algorithm method, const QByteArray& key = …)
.
Constructs an object that can be used to create a cryptographic hash from data using method method and key key.
sourcepub unsafe fn new_1a(method: Algorithm) -> CppBox<QMessageAuthenticationCode>
pub unsafe fn new_1a(method: Algorithm) -> CppBox<QMessageAuthenticationCode>
Constructs an object that can be used to create a cryptographic hash from data using method method and key key.
Calls C++ function: [constructor] void QMessageAuthenticationCode::QMessageAuthenticationCode(QCryptographicHash::Algorithm method)
.
Constructs an object that can be used to create a cryptographic hash from data using method method and key key.
sourcepub unsafe fn reset(&self)
pub unsafe fn reset(&self)
Resets message data. Calling this method doesn't affect the key.
Calls C++ function: void QMessageAuthenticationCode::reset()
.
Resets message data. Calling this method doesn’t affect the key.
sourcepub unsafe fn result(&self) -> CppBox<QByteArray>
pub unsafe fn result(&self) -> CppBox<QByteArray>
Returns the final authentication code.
Calls C++ function: QByteArray QMessageAuthenticationCode::result() const
.
Returns the final authentication code.
See also QByteArray::toHex().
sourcepub unsafe fn set_key(&self, key: impl CastInto<Ref<QByteArray>>)
pub unsafe fn set_key(&self, key: impl CastInto<Ref<QByteArray>>)
Sets secret key. Calling this method automatically resets the object state.
Calls C++ function: void QMessageAuthenticationCode::setKey(const QByteArray& key)
.
Sets secret key. Calling this method automatically resets the object state.