CopperSpice API
1.9.2
|
Provides a way to generate hash-based message authentication codes. More...
Public Methods | |
QMessageAuthenticationCode (QCryptographicHash::Algorithm method, const QByteArray &key=QByteArray ()) | |
~QMessageAuthenticationCode () | |
void | addData (const char *data, int length) |
void | addData (const QByteArray &data) |
bool | addData (QIODevice *device) |
void | reset () |
QByteArray | result () const |
void | setKey (const QByteArray &key) |
Static Public Methods | |
static QByteArray | hash (const QByteArray &message, const QByteArray &key, QCryptographicHash::Algorithm method) |
QMessageAuthenticationCode supports all cryptographic hashes which are supported by QCryptographicHash.
To generate a message authentication code pass a hash algorithm to the constructor of QMessageAuthenticationCode then set the key and message using the setKey() and addData() methods. The result() methods returns the message authentication code.
Alternatively this effect can be achieved by providing message key and method to the hash() method.
|
explicit |
Constructs an object which can be used to create a cryptographic hash from data using the given method and key.
QMessageAuthenticationCode::~QMessageAuthenticationCode | ( | ) |
Destroys the QMessageAuthenticationCode object.
void QMessageAuthenticationCode::addData | ( | const char * | data, |
int | length | ||
) |
Adds the first length chars of data to the message.
void QMessageAuthenticationCode::addData | ( | const QByteArray & | data | ) |
Adds the data to the message.
bool QMessageAuthenticationCode::addData | ( | QIODevice * | device | ) |
Reads data from device until the end of the file is reached. Adds the data read from the file to this message. Returns true if reading was successful. The I/O device must be already opened.
|
static |
Returns the authentication code for the message using the key and the method.
void QMessageAuthenticationCode::reset | ( | ) |
Resets message data. Calling this method does not affect the key.
QByteArray QMessageAuthenticationCode::result | ( | ) | const |
Returns the final authentication code.
void QMessageAuthenticationCode::setKey | ( | const QByteArray & | key | ) |
Sets secret key. Calling this method automatically resets the object state.