[−][src]Struct qt_core::QMessageAuthenticationCode
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();
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)
.
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)
.
This function overloads addData().
pub unsafe fn add_data_q_io_device(
&self,
device: impl CastInto<Ptr<QIODevice>>
) -> bool
[src]
&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.
pub unsafe fn hash(
message: impl CastInto<Ref<QByteArray>>,
key: impl CastInto<Ref<QByteArray>>,
method: Algorithm
) -> CppBox<QByteArray>
[src]
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.
pub unsafe fn new_2a(
method: Algorithm,
key: impl CastInto<Ref<QByteArray>>
) -> CppBox<QMessageAuthenticationCode>
[src]
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.
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)
.
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()
.
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
.
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)
.
Sets secret key. Calling this method automatically resets the object state.
Trait Implementations
impl CppDeletable for QMessageAuthenticationCode
[src]
Auto Trait Implementations
impl RefUnwindSafe for QMessageAuthenticationCode
impl Send for QMessageAuthenticationCode
impl Sync for QMessageAuthenticationCode
impl Unpin for QMessageAuthenticationCode
impl UnwindSafe for QMessageAuthenticationCode
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> CastInto<U> for T where
U: CastFrom<T>,
[src]
U: CastFrom<T>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> StaticUpcast<T> for T
[src]
unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,