MuldeR's Utilities for Qt
MUtilities
|
This abstract class specifies the generic interface for all support hash algorithms. More...
#include <Hash.h>
Public Member Functions | |
bool | update (const quint8 *const data, const quint32 len) |
Process the next chunk of input data. More... | |
bool | update (const QByteArray &data) |
Process the next chunk of input data. More... | |
bool | update (QFile &file) |
Process the next chunk of input data. More... | |
QByteArray | digest (const bool bAsHex=true) |
Retrieve the hash value. More... | |
Protected Member Functions | |
Hash (const char *=NULL) | |
virtual bool | process (const quint8 *const data, const quint32 len)=0 |
virtual QByteArray | finalize (void)=0 |
This abstract class specifies the generic interface for all support hash algorithms.
In order to compute a hash value (digest) call the the Hash::update() function repeatedly until all input data (i.e. the complete "message") has been processed. Then call the Hash::digest() function to retrieve the final hash value.
All overloads of the Hash::update() function may be called in an interleaved fashion as needed.
This class is not thread-safe, i.e. do not call the same Hash instance from difference threads, unless serialization is ensured (e.g. by means of a Mutex). It is safe, however, to call different different Hash instances from difference threads concurrently.
|
inline |
Retrieve the hash value.
This function is used to retrieve the final hash value (digest), after all input data has been processed successfully.
bAsHex | If set to true , the function returns the hash value as a Hexadecimal-encoded ASCII string; if set to false , the function returns the hash value as "raw" bytes. |
bAsHex
parameter.
|
inline |
Process the next chunk of input data.
Updates the internal state of the hash function by processing the next chunk of input that. Can be called repeatedly, until until all input data has been processed.
data | A read-only pointer to the memory buffer holding the input data to be processed. |
len | The length of the input data, in bytes. The data parameter must be pointing to a memory buffer that is at least len bytes in size. |
true
, if the input data was processed successfully; otherwise it returns false
.
|
inline |
Process the next chunk of input data.
Updates the internal state of the hash function by processing the next chunk of input that. Can be called repeatedly, until until all input data has been processed.
data | A read-only reference to a QByteArray object holding the input data to be processed. All bytes in the QByteArray object will be processed. |
true
, if the input data was processed successfully; otherwise it returns false
. bool MUtils::Hash::Hash::update | ( | QFile & | file | ) |
Process the next chunk of input data.
Updates the internal state of the hash function by processing the next chunk of input that. Can be called repeatedly, until until all input data has been processed.
data | A reference to a QFile object. The QFile object must be open and readable. All data from the current file position to the end of the file will be processed. |
true
, if all data in the file was processed successfully; otherwise (e.g. in case of file read errors) it returns false
.