[][src]Struct qt_core::QMessageAuthenticationCode

#[repr(C)]pub struct QMessageAuthenticationCode { /* fields omitted */ }

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();

Methods

impl QMessageAuthenticationCode[src]

pub unsafe fn add_data_char_int(&self, data: *const c_char, length: c_int)[src]

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.

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

This function overloads addData().

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

C++ documentation:

This function overloads addData().

pub unsafe fn add_data_q_io_device(
    &self,
    device: impl CastInto<Ptr<QIODevice>>
) -> bool
[src]

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.

pub unsafe fn hash(
    message: impl CastInto<Ref<QByteArray>>,
    key: impl CastInto<Ref<QByteArray>>,
    method: Algorithm
) -> CppBox<QByteArray>
[src]

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.

pub unsafe fn new_2a(
    method: Algorithm,
    key: impl CastInto<Ref<QByteArray>>
) -> CppBox<QMessageAuthenticationCode>
[src]

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.

pub unsafe fn new_1a(method: Algorithm) -> CppBox<QMessageAuthenticationCode>[src]

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.

pub unsafe fn reset(&self)[src]

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.

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

Returns the final authentication code.

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

C++ documentation:

Returns the final authentication code.

See also QByteArray::toHex().

pub unsafe fn set_key(&self, key: impl CastInto<Ref<QByteArray>>)[src]

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

impl CppDeletable for QMessageAuthenticationCode[src]

unsafe fn delete(&self)[src]

Destroys the object.

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

C++ documentation:

Destroys the object.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.