This class represents the baseclass for all subwrappers. More...
#include <hl_hashwrapper.h>
Public Member Functions | |
hashwrapper (void) | |
Default Konstruktor. | |
virtual | ~hashwrapper (void) |
Default destructor. | |
virtual void | test (void) |
Method for testing the concrete implementation. | |
virtual std::string | getHashFromString (std::string text) |
This method creates a hash based on the given string. | |
virtual std::string | getHashFromFile (std::string filename) |
This method creates a hash from a given file. | |
Protected Member Functions | |
virtual std::string | hashIt (void)=0 |
This method finalizes the hash process and returns the hash as std::string. | |
virtual std::string | convToString (unsigned char *data)=0 |
This internal member-function convertes the hash-data to a std::string (HEX). | |
virtual void | updateContext (unsigned char *data, unsigned int len)=0 |
This method adds the given data to the current hash context. | |
virtual void | resetContext (void)=0 |
This method resets the current hash context. In other words: It starts a new hash process. | |
virtual std::string | getTestHash (void)=0 |
This method should return the hash of the test-string "The quick brown fox jumps over the lazy
dog". |
This class represents the baseclass for all subwrappers.
hashwrapper is the abstract base class of all subwrappers like md5wrapper or sha1wrapper. This class implements two simple and easy to use memberfunctions to create a hash based on a string or a file. ( getHashFromString() and getHashFromFile() )
getHashFromString() calls resetContext(), updateContext() and hashIt() in this order. These three memberfunctions are pure virtual and have to be implemented by the subclasses.
getHashFromFile() calls resetContext() before reading the specified file in 1024 byte blocks which are forwarded to the hash context by calling updateContext(). Finaly hashIt() is called to return the hash.
virtual std::string hashwrapper::convToString | ( | unsigned char * | data | ) | [protected, pure virtual] |
This internal member-function convertes the hash-data to a std::string (HEX).
This memberfunction is pure virtual and has to be implemented by the subclass
data | The hash-data to covert into HEX |
Implemented in md5wrapper, sha1wrapper, sha256wrapper, sha384wrapper, and sha512wrapper.
virtual std::string hashwrapper::getHashFromFile | ( | std::string | filename | ) | [inline, virtual] |
This method creates a hash from a given file.
First of all resetContext() is called before reading the specified file in 1024 byte blocks which are forwarded to the hash context by calling updateContext(). Finaly hashIt() is called to return the hash. These three memberfunctions are pure virtual and have to be implemented by the subclasses.
filename | The file to created a hash from |
Throws | a hlException if the specified file could not be opened. |
virtual std::string hashwrapper::getHashFromString | ( | std::string | text | ) | [inline, virtual] |
This method creates a hash based on the given string.
This memberfunctions calls resetContext(), updateContext() and hashIt() in this order. These three memberfunctions are pure virtual and have to be implemented by the subclasses.
text | The text to create a hash from. This parameter is forwarded to updateContext() |
virtual std::string hashwrapper::hashIt | ( | void | ) | [protected, pure virtual] |
This method finalizes the hash process and returns the hash as std::string.
This memberfunction is pure virtual and has to be implemented by the subclass
Implemented in md5wrapper, sha1wrapper, sha256wrapper, sha384wrapper, and sha512wrapper.
virtual void hashwrapper::resetContext | ( | void | ) | [protected, pure virtual] |
This method resets the current hash context. In other words: It starts a new hash process.
This memberfunction is pure virtual and has to be implemented by the subclass
Implemented in md5wrapper, sha1wrapper, sha256wrapper, sha384wrapper, and sha512wrapper.
virtual void hashwrapper::updateContext | ( | unsigned char * | data, | |
unsigned int | len | |||
) | [protected, pure virtual] |
This method adds the given data to the current hash context.
This memberfunction is pure virtual and has to be implemented by the subclass
data | The data to add to the current context | |
len | The length of the data to add |
Implemented in md5wrapper, sha1wrapper, sha256wrapper, sha384wrapper, and sha512wrapper.