md5wrapper Class Reference

This class represents the MD5 wrapper-class. More...

#include <hl_md5wrapper.h>

Inheritance diagram for md5wrapper:
hashwrapper

List of all members.

Public Member Functions

 md5wrapper ()
 default constructor
virtual ~md5wrapper ()
 default destructor

Protected Member Functions

virtual std::string hashIt (void)
 This method ends the hash process and returns the hash as string.
virtual std::string convToString (unsigned char *data)
 This internal member-function convertes the hash-data to a std::string (HEX).
virtual void updateContext (unsigned char *data, unsigned int len)
 This method adds the given data to the current hash context.
virtual void resetContext (void)
 This method resets the current hash context. In other words: It starts a new hash process.
virtual std::string getTestHash (void)
 This method should return the hash of the test-string "The quick brown fox jumps over the lazy dog".

Protected Attributes

MD5md5
HL_MD5_CTX ctx

Detailed Description

This class represents the MD5 wrapper-class.

You can use this class to easily create a md5 hash. Just create an instance of md5wrapper and call the inherited memberfunctions getHashFromString() and getHashFromFile() to create a hash based on a string or a file.

Have a look at the following example:

#include <hashlibpp.h>
#include <string>
#include <iostream>  //for "cerr"

/*
 * creating a wrapper object
 */
hashwrapper *myWrapper = new md5wrapper();

try
{
        /*
         * create a hash from a string
         */
        std::string hash1 = myWrapper->getHashFromString("Hello World");

        /*
         * create a hash based on a file
         */
        std::string hash2 = myWrapper->getHashFromFile("README.TXT");
}
catch(hlException &e)
{

        std::cerr << "Error(" 
                  << e.error_number()
                  << "): "
                  << e.erro_message()
                  << std::endl;
}

delete myWrapper;

md5wrapper implements resetContext(), updateContext() and hashIt() to create a hash.


Member Function Documentation

std::string md5wrapper::convToString ( unsigned char *  data  )  [protected, virtual]

This internal member-function convertes the hash-data to a std::string (HEX).

Parameters:
data The hash-data to covert into HEX
Returns:
the converted data as std::string

Implements hashwrapper.

std::string md5wrapper::hashIt ( void   )  [protected, virtual]

This method ends the hash process and returns the hash as string.

Returns:
the hash as std::string

Implements hashwrapper.

void md5wrapper::updateContext ( unsigned char *  data,
unsigned int  len 
) [protected, virtual]

This method adds the given data to the current hash context.

Parameters:
data The data to add to the current context
len The length of the data to add

Implements hashwrapper.


Member Data Documentation

MD5 context

MD5* md5wrapper::md5 [protected]

MD5 access


The documentation for this class was generated from the following files:
Generated on Thu Oct 13 20:06:35 2011 for hashlib++ by  doxygen 1.6.3