diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-13 15:07:21 +0400 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-13 15:07:21 +0400 |
| commit | 802410f7a3bdf2db3823f96e122bf1db45bf6a85 (patch) | |
| tree | b761182cd6a6cf47e75b168614b414fd1b5e089e /CryptClass/HASHCrypt.cpp | |
| parent | 34b47f8e08eff519f6c8372f2e4ce5b24267614c (diff) | |
| parent | c113e7b5f46a3434f017de3f2c9f83a002b246f1 (diff) | |
Merge branch 'PARSER'
Diffstat (limited to 'CryptClass/HASHCrypt.cpp')
| -rw-r--r-- | CryptClass/HASHCrypt.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/CryptClass/HASHCrypt.cpp b/CryptClass/HASHCrypt.cpp index cd0dab6..eed9cb5 100644 --- a/CryptClass/HASHCrypt.cpp +++ b/CryptClass/HASHCrypt.cpp @@ -8,13 +8,12 @@ * */ + //----- class ----- #include "HASHCrypt.hpp" - - //Constructor HASHCrypt::HASHCrypt(){ } @@ -25,6 +24,7 @@ HASHCrypt::~HASHCrypt(){ +//Contruct MD5 over 128 bits and put it into digest void HASHCrypt::getMD5_128(std::string chain, byte* digest, int size){ //Digest size controller @@ -37,6 +37,8 @@ void HASHCrypt::getMD5_128(std::string chain, byte* digest, int size){ } + +//Contruct SHA-256 and put it into digest void HASHCrypt::getSHA_256(std::string chain, byte* digest, int size){ //Digest size controller @@ -50,27 +52,6 @@ void HASHCrypt::getSHA_256(std::string chain, byte* digest, int size){ } -//Check the size of the digest -void HASHCrypt::checkDigestSize(int sizeRequired, int size){ - try{ - if(size !=sizeRequired){ - throw this->getInvalidDigestSizeError(sizeRequired, size); - } - - } - catch(std::string erreur){ - std::cerr << erreur <<std::endl; - std::exit(EXIT_FAILURE); - } -} - -//Make the error -std::string HASHCrypt::getInvalidDigestSizeError(int sizeRequired, int size){ - std::ostringstream erreurStream; - erreurStream << "Invalid digest size ! ("<< sizeRequired <<" bytes required and "<< size <<" given)"; - return erreurStream.str(); -} - //Compare 2 digest (same size) bool HASHCrypt::compareDigest(byte* digest1, byte* digest2, int size){ @@ -96,6 +77,7 @@ bool HASHCrypt::compareDigest(byte* digest1, byte* digest2, int size){ } + //Convert digest to string std::string HASHCrypt::digestToString(byte* digest, int size){ @@ -107,3 +89,28 @@ std::string HASHCrypt::digestToString(byte* digest, int size){ return output; } + + + +//Check the size of the digest +void HASHCrypt::checkDigestSize(int sizeRequired, int size){ + try{ + if(size !=sizeRequired){ + throw this->getInvalidDigestSizeError(sizeRequired, size); + } + + } + catch(std::string erreur){ + std::cerr << erreur <<std::endl; + std::exit(EXIT_FAILURE); + } +} + + + +//Make the error +std::string HASHCrypt::getInvalidDigestSizeError(int sizeRequired, int size){ + std::ostringstream erreurStream; + erreurStream << "Invalid digest size ! ("<< sizeRequired <<" bytes required and "<< size <<" given)"; + return erreurStream.str(); +} |
