.TH "KMD5" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KMD5 \- An adapted C++ implementation of RSA Data Securities MD5 algorithm.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kmdcodec.h>\fP
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "typedef unsigned char \fBDigest\fP [16]"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKMD5\fP (const char *in, int len=-1)"
.br
.ti -1c
.RI "\fBKMD5\fP (const \fBQByteArray\fP &a)"
.br
.ti -1c
.RI "\fBKMD5\fP (const \fBQCString\fP &a)"
.br
.ti -1c
.RI "void \fBupdate\fP (const char *in, int len=-1)"
.br
.ti -1c
.RI "void \fBupdate\fP (const unsigned char *in, int len=-1)"
.br
.ti -1c
.RI "void \fBupdate\fP (const \fBQByteArray\fP &in)"
.br
.ti -1c
.RI "void \fBupdate\fP (const \fBQCString\fP &in)"
.br
.ti -1c
.RI "bool \fBupdate\fP (\fBQIODevice\fP &file)"
.br
.ti -1c
.RI "void \fBreset\fP ()"
.br
.ti -1c
.RI "const Digest & \fBrawDigest\fP ()"
.br
.ti -1c
.RI "void \fBrawDigest\fP (KMD5::Digest &bin)"
.br
.ti -1c
.RI "\fBQCString\fP \fBhexDigest\fP ()"
.br
.ti -1c
.RI "void \fBhexDigest\fP (\fBQCString\fP &)"
.br
.ti -1c
.RI "\fBQCString\fP \fBbase64Digest\fP ()"
.br
.ti -1c
.RI "bool \fBverify\fP (const KMD5::Digest &digest)"
.br
.ti -1c
.RI "bool \fBverify\fP (const \fBQCString\fP &)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "void \fBtransform\fP (const unsigned char buffer[64])"
.br
.ti -1c
.RI "void \fBfinalize\fP ()"
.br
.in -1c
.SH "Detailed Description"
.PP 
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.
.PP
KMD5 is state-based, that means you can add new contents with \fBupdate()\fP 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 \fBreset()\fP 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.
.PP
\fBUsage:\fP 
.PP
A common usage of this class:
.PP
.PP
.nf
 const char* test1;
 KMD5::Digest rawResult;

 test1 = 'This is a simple test.';
 KMD5 context (test1);
 cout << 'Hex Digest output: ' << context.hexDigest().data() << endl;
.fi
.PP
.PP
To cut down on the unnecessary overhead of creating multiple KMD5 objects, you can simply invoke \fBreset()\fP to reuse the same object in making another calculation:
.PP
.PP
.nf
 context.reset ();
 context.update ('TWO');
 context.update ('THREE');
 cout << 'Hex Digest output: ' << context.hexDigest().data() << endl;
.fi
.PP
.PP
\fBAuthor:\fP
.RS 4
Dirk Mueller <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org> 
.RE
.PP

.PP
Definition at line 402 of file kmdcodec.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KMD5::KMD5 (const char * in, int len = \fC-1\fP)"
.PP
Constructor that updates the digest for the given string. 
.PP
\fBParameters:\fP
.RS 4
\fIin\fP C string or binary data 
.br
\fIlen\fP if negative, calculates the length by using strlen on the first parameter, otherwise it trusts the given length (does not stop on NUL byte). 
.RE
.PP

.PP
Definition at line 756 of file kmdcodec.cpp.
.PP
References update().
.SS "KMD5::KMD5 (const \fBQByteArray\fP & a)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
Same as above except it accepts a \fBQByteArray\fP as its argument. 
.PP
Definition at line 762 of file kmdcodec.cpp.
.PP
References update().
.SS "KMD5::KMD5 (const \fBQCString\fP & a)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
Same as above except it accepts a \fBQCString\fP as its argument. 
.PP
Definition at line 768 of file kmdcodec.cpp.
.PP
References update().
.SH "Member Function Documentation"
.PP 
.SS "void KMD5::update (const char * in, int len = \fC-1\fP)\fC [inline]\fP"
.PP
Updates the message to be digested. 
.PP
Be sure to add all data before you read the digest. After reading the digest, you can \fBnot\fP add more data!
.PP
\fBParameters:\fP
.RS 4
\fIin\fP message to be added to digest 
.br
\fIlen\fP the length of the given message. 
.RE
.PP

.PP
Definition at line 442 of file kmdcodec.h.
.PP
Referenced by finalize(), KMD5(), and update().
.SS "void KMD5::update (const unsigned char * in, int len = \fC-1\fP)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
.PP
Definition at line 784 of file kmdcodec.cpp.
.PP
References endl(), and transform().
.SS "void KMD5::update (const \fBQByteArray\fP & in)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
\fBParameters:\fP
.RS 4
\fIin\fP message to be added to the digest (\fBQByteArray\fP). 
.RE
.PP

.PP
Definition at line 774 of file kmdcodec.cpp.
.PP
References update().
.SS "void KMD5::update (const \fBQCString\fP & in)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
\fBParameters:\fP
.RS 4
\fIin\fP message to be added to the digest (\fBQCString\fP). 
.RE
.PP

.PP
Definition at line 779 of file kmdcodec.cpp.
.PP
References update().
.SS "bool KMD5::update (\fBQIODevice\fP & file)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
.PP
reads the data from an I/O device, i.e. from a file (\fBQFile\fP).
.PP
NOTE that the file must be open for reading.
.PP
\fBParameters:\fP
.RS 4
\fIfile\fP a pointer to FILE as returned by calls like f{d,re}open
.RE
.PP
\fBReturns:\fP
.RS 4
false if an error occurred during reading. 
.RE
.PP

.PP
Definition at line 827 of file kmdcodec.cpp.
.PP
References update().
.SS "void KMD5::reset ()"
.PP
Calling this function will reset the calculated message digest. 
.PP
Use this method to perform another message digest calculation without recreating the KMD5 object. 
.PP
Definition at line 938 of file kmdcodec.cpp.
.SS "const KMD5::Digest & KMD5::rawDigest ()"
.PP
\fBReturns:\fP
.RS 4
the raw representation of the digest 
.RE
.PP

.PP
Definition at line 886 of file kmdcodec.cpp.
.PP
References finalize().
.PP
Referenced by verify().
.SS "void KMD5::rawDigest (KMD5::Digest & bin)"
.PP
Fills the given array with the binary representation of the message digest. 
.PP
Use this method if you do not want to worry about making copy of the digest once you obtain it.
.PP
\fBParameters:\fP
.RS 4
\fIbin\fP an array of 16 characters ( char[16] ) 
.RE
.PP

.PP
Definition at line 892 of file kmdcodec.cpp.
.PP
References finalize().
.SS "\fBQCString\fP KMD5::hexDigest ()"
.PP
Returns the value of the calculated message digest in a hexadecimal representation. 
.PP
Definition at line 899 of file kmdcodec.cpp.
.PP
References finalize().
.PP
Referenced by verify().
.SS "void KMD5::hexDigest (\fBQCString\fP &)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
.PP
Definition at line 912 of file kmdcodec.cpp.
.PP
References finalize(), and QCString::resize().
.SS "\fBQCString\fP KMD5::base64Digest ()"
.PP
Returns the value of the calculated message digest in a base64-encoded representation. 
.PP
Definition at line 922 of file kmdcodec.cpp.
.PP
References KCodecs::base64Encode(), and finalize().
.SS "bool KMD5::verify (const KMD5::Digest & digest)"
.PP
returns true if the calculated digest for the given message matches the given one. 
.PP
Definition at line 874 of file kmdcodec.cpp.
.PP
References finalize(), and rawDigest().
.SS "bool KMD5::verify (const \fBQCString\fP &)"
.PP
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 
.PP
Definition at line 880 of file kmdcodec.cpp.
.PP
References finalize(), and hexDigest().
.SS "void KMD5::transform (const unsigned char buffer[64])\fC [protected]\fP"
.PP
Performs the real update work. 
.PP
Note that length is implied to be 64. 
.PP
Definition at line 954 of file kmdcodec.cpp.
.PP
Referenced by update().
.SS "void KMD5::finalize ()\fC [protected]\fP"
.PP
finalizes the digest 
.PP
Definition at line 838 of file kmdcodec.cpp.
.PP
References update().
.PP
Referenced by base64Digest(), hexDigest(), rawDigest(), and verify().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
