#[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.

C++ documentation:

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

source

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).

C++ documentation:

Adds the first length chars of data to the message.

source

pub unsafe fn add_data_q_byte_array(&self, data: impl CastInto<Ref<QByteArray>>)

This function overloads addData().

Calls C++ function: void QMessageAuthenticationCode::addData(const QByteArray& data).

C++ documentation:

This function overloads addData().

source

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).

C++ documentation:

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.

source

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).

C++ documentation:

Returns the authentication code for the message message using the key key and the method method.

source

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 = …).

C++ documentation:

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

source

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).

C++ documentation:

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

source

pub unsafe fn reset(&self)

Resets message data. Calling this method doesn't affect the key.

Calls C++ function: void QMessageAuthenticationCode::reset().

C++ documentation:

Resets message data. Calling this method doesn’t affect the key.

source

pub unsafe fn result(&self) -> CppBox<QByteArray>

Returns the final authentication code.

Calls C++ function: QByteArray QMessageAuthenticationCode::result() const.

C++ documentation:

Returns the final authentication code.

See also QByteArray::toHex().

source

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).

C++ documentation:

Sets secret key. Calling this method automatically resets the object state.

Trait Implementations§

source§

impl CppDeletable for QMessageAuthenticationCode

source§

unsafe fn delete(&self)

Destroys the object.

Calls C++ function: [destructor] void QMessageAuthenticationCode::~QMessageAuthenticationCode().

C++ documentation:

Destroys the object.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.