#include <kmdcodec.h>
Public Types | |
typedef unsigned char | Digest[16] |
Public Member Functions | |
KMD5 (const char *in, int len=-1) | |
KMD5 (const TQByteArray &a) | |
KMD5 (const TQCString &a) | |
void | update (const char *in, int len=-1) |
void | update (const unsigned char *in, int len=-1) |
void | update (const TQByteArray &in) |
void | update (const TQCString &in) |
bool | update (TQIODevice &file) |
void | reset () |
const Digest & | rawDigest () |
void | rawDigest (KMD5::Digest &bin) |
TQCString | hexDigest () |
void | hexDigest (TQCString &) |
TQCString | base64Digest () |
bool | verify (const KMD5::Digest &digest) |
bool | verify (const TQCString &) |
Protected Member Functions | |
void | transform (const unsigned char buffer[64]) |
void | finalize () |
Detailed Description
An adapted C++ implementation of RSA Data Securities MD5 algorithm.
The default constructor is designed to provide much the same functionality as the most commonly used C-implementation, while the other three constructors are meant to further simplify the process of obtaining a digest by calculating the result in a single step.
KMD5 is state-based, that means you can add new contents with update() as long as you didn't request the digest value yet. After the digest value was requested, the object is "finalized" and you have to call reset() to be able to do another calculation with it. The reason for this behavior is that upon requesting the message digest KMD5 has to pad the received contents up to a 64 byte boundary to calculate its value. After this operation it is not possible to resume consuming data.
Usage:
A common usage of this class:
To cut down on the unnecessary overhead of creating multiple KMD5 objects, you can simply invoke reset() to reuse the same object in making another calculation:
Definition at line 402 of file kmdcodec.h.
Constructor & Destructor Documentation
◆ KMD5() [1/3]
KMD5::KMD5 | ( | const char * | in, |
int | len = -1 |
||
) |
Constructor that updates the digest for the given string.
- Parameters
-
in C string or binary data len if negative, calculates the length by using strlen on the first parameter, otherwise it trusts the given length (does not stop on NUL byte).
Definition at line 760 of file kmdcodec.cpp.
◆ KMD5() [2/3]
KMD5::KMD5 | ( | const TQByteArray & | a | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as above except it accepts a TQByteArray as its argument.
Definition at line 766 of file kmdcodec.cpp.
◆ KMD5() [3/3]
KMD5::KMD5 | ( | const TQCString & | a | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as above except it accepts a TQCString as its argument.
Definition at line 772 of file kmdcodec.cpp.
Member Function Documentation
◆ base64Digest()
TQCString KMD5::base64Digest | ( | ) |
Returns the value of the calculated message digest in a base64-encoded representation.
Definition at line 926 of file kmdcodec.cpp.
◆ finalize()
|
protected |
finalizes the digest
Definition at line 842 of file kmdcodec.cpp.
◆ hexDigest() [1/2]
TQCString KMD5::hexDigest | ( | ) |
Returns the value of the calculated message digest in a hexadecimal representation.
Definition at line 903 of file kmdcodec.cpp.
◆ hexDigest() [2/2]
void KMD5::hexDigest | ( | TQCString & | s | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 916 of file kmdcodec.cpp.
◆ rawDigest() [1/2]
const KMD5::Digest & KMD5::rawDigest | ( | ) |
- Returns
- the raw representation of the digest
Definition at line 890 of file kmdcodec.cpp.
◆ rawDigest() [2/2]
void KMD5::rawDigest | ( | KMD5::Digest & | bin | ) |
Fills the given array with the binary representation of the message digest.
Use this method if you do not want to worry about making copy of the digest once you obtain it.
- Parameters
-
bin an array of 16 characters ( char[16] )
Definition at line 896 of file kmdcodec.cpp.
◆ reset()
void KMD5::reset | ( | ) |
Calling this function will reset the calculated message digest.
Use this method to perform another message digest calculation without recreating the KMD5 object.
Definition at line 942 of file kmdcodec.cpp.
◆ transform()
|
protected |
Performs the real update work.
Note that length is implied to be 64.
Definition at line 958 of file kmdcodec.cpp.
◆ update() [1/5]
|
inline |
Updates the message to be digested.
Be sure to add all data before you read the digest. After reading the digest, you can not add more data!
- Parameters
-
in message to be added to digest len the length of the given message.
Definition at line 442 of file kmdcodec.h.
◆ update() [2/5]
void KMD5::update | ( | const TQByteArray & | in | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
in message to be added to the digest (TQByteArray).
Definition at line 778 of file kmdcodec.cpp.
◆ update() [3/5]
void KMD5::update | ( | const TQCString & | in | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
in message to be added to the digest (TQCString).
Definition at line 783 of file kmdcodec.cpp.
◆ update() [4/5]
void KMD5::update | ( | const unsigned char * | in, |
int | len = -1 |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 788 of file kmdcodec.cpp.
◆ update() [5/5]
bool KMD5::update | ( | TQIODevice & | file | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.reads the data from an I/O device, i.e.
from a file (TQFile).
NOTE that the file must be open for reading.
- Parameters
-
file a pointer to FILE as returned by calls like f{d,re}open
- Returns
- false if an error occurred during reading.
Definition at line 831 of file kmdcodec.cpp.
◆ verify() [1/2]
bool KMD5::verify | ( | const KMD5::Digest & | digest | ) |
returns true if the calculated digest for the given message matches the given one.
Definition at line 878 of file kmdcodec.cpp.
◆ verify() [2/2]
bool KMD5::verify | ( | const TQCString & | hexdigest | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 884 of file kmdcodec.cpp.
The documentation for this class was generated from the following files: