KMD5

#include <kmd5.h>

Public Types

typedef unsigned char Digest[16]
 

Public Member Functions

 KMD5 (const char *in, int len=-1)
 
 KMD5 (const QByteArray &a)
 
QByteArray base64Digest ()
 
QByteArray hexDigest ()
 
void hexDigest (QByteArray &)
 
const Digest & rawDigest ()
 
void rawDigest (KMD5::Digest &bin)
 
void reset ()
 
void update (const char *in, int len=-1)
 
void update (const unsigned char *in, int len=-1)
 
void update (const QByteArray &in)
 
bool update (QIODevice &file)
 
bool verify (const KMD5::Digest &digest)
 
bool verify (const QByteArray &)
 

Protected Member Functions

void finalize ()
 
void transform (const unsigned char buffer[64])
 

Detailed Description

An adapted C++ implementation of RSA Data Securities MD5 algorithm.

DEPRECATED. please use QCryptographicHash instead

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:

const char* test1;
KMD5::Digest rawResult;
test1 = "This is a simple test.";
KMD5 context (test1);
cout << "Hex Digest output: " << context.hexDigest().data() << endl;

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:

context.reset ();
context.update ("TWO");
context.update ("THREE");
cout << "Hex Digest output: " << context.hexDigest().data() << endl;
Author
Dirk Mueller muell[email protected][email protected][email protected]de.or[email protected]g, Dawit Alemayehu adawi[email protected][email protected][email protected]e.org
Deprecated:
See also
QCryptographicHash

Definition at line 94 of file kmd5.h.

Constructor & Destructor Documentation

KMD5::KMD5 ( const char *  in,
int  len = -1 
)
explicit

Constructor that updates the digest for the given string.

Parameters
inC string or binary data
lenif 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 66 of file kmd5.cpp.

KMD5::KMD5 ( const QByteArray a)
explicit

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 QByteArray as its argument.

Definition at line 72 of file kmd5.cpp.

Member Function Documentation

QByteArray KMD5::base64Digest ( )

Returns the value of the calculated message digest in a base64-encoded representation.

Deprecated:
please use QCryptographicHash::result().toBase64() instead

Definition at line 233 of file kmd5.cpp.

void KMD5::finalize ( )
protected

finalizes the digest

Definition at line 150 of file kmd5.cpp.

QByteArray KMD5::hexDigest ( )

Returns the value of the calculated message digest in a hexadecimal representation.

Deprecated:
please use QCryptographicHash::result().toHex() instead

Definition at line 210 of file kmd5.cpp.

void KMD5::hexDigest ( QByteArray 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 223 of file kmd5.cpp.

const KMD5::Digest & KMD5::rawDigest ( )
Returns
the raw representation of the digest
Deprecated:
please use QCryptographicHash::result instead

Definition at line 198 of file kmd5.cpp.

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
binan array of 16 characters ( char[16] )

Definition at line 204 of file kmd5.cpp.

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.

Deprecated:
please use QCryptographicHash::reset() instead

Definition at line 245 of file kmd5.cpp.

void KMD5::transform ( const unsigned char  buffer[64])
protected

Performs the real update work.

Note that length is implied to be 64.

Definition at line 261 of file kmd5.cpp.

void KMD5::update ( const char *  in,
int  len = -1 
)

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
inmessage to be added to digest
lenthe length of the given message.
Deprecated:
please use QCryptographicHash::addData instead

Definition at line 87 of file kmd5.cpp.

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.please use QCryptographicHash::addData instead.

Definition at line 92 of file kmd5.cpp.

void KMD5::update ( const QByteArray in)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
inmessage to be added to the digest (QByteArray).
Deprecated:
please use QCryptographicHash::addData instead

Definition at line 82 of file kmd5.cpp.

bool KMD5::update ( QIODevice 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 (QFile).

NOTE that the file must be open for reading.

Parameters
filea pointer to FILE as returned by calls like f{d,re}open
Returns
false if an error occurred during reading.
Deprecated:
please use QCryptographicHash::addData instead

Definition at line 138 of file kmd5.cpp.

bool KMD5::verify ( const KMD5::Digest &  digest)

returns true if the calculated digest for the given message matches the given one.

Definition at line 186 of file kmd5.cpp.

bool KMD5::verify ( const QByteArray 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 192 of file kmd5.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:56:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.