diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-09 12:51:23 +0400 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-09 12:51:23 +0400 |
| commit | 7d2c4734224eb7f6cf699bc84f505c06c4394b35 (patch) | |
| tree | 070330590915595ec740acfeea5a92c742f427fb /CryptClass/HASHCrypt.cpp | |
| parent | 1574c191c3a6909e2b932fb32d6c63dc89e264b1 (diff) | |
AES first release. Add method to HASHCrypt class.
Diffstat (limited to 'CryptClass/HASHCrypt.cpp')
| -rw-r--r-- | CryptClass/HASHCrypt.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/CryptClass/HASHCrypt.cpp b/CryptClass/HASHCrypt.cpp index 4c42ef3..11fc04c 100644 --- a/CryptClass/HASHCrypt.cpp +++ b/CryptClass/HASHCrypt.cpp @@ -42,6 +42,8 @@ void HASHCrypt::getSHA_256(std::string chain, byte* digest, int size){ //Create the SHA-256 on digest parameter CryptoPP::SHA256 hash; hash.CalculateDigest( digest, (byte*) chain.c_str(), chain.length() ); + + } @@ -66,3 +68,37 @@ std::string HASHCrypt::getInvalidDigestSizeError(int sizeRequired, int size){ return erreurStream.str(); } + +bool HASHCrypt::compareDigest(byte* digest1, byte* digest2, int size){ + + //Try is more safe + try + { + //Compare the two digest + for(int i=0; i<size; i++){ + //Return false if digest are different + if(digest1[i] != digest2[i]){ + return false; + } + } + } + catch (std::exception& e) + { + std::cerr << "Exception catched : " << e.what() << std::endl; + } + + //Return true if digest are equals + return true; +} + +//Convert digest to string +std::string HASHCrypt::digestToString(byte* digest, int size){ + + CryptoPP::HexEncoder encoder; + std::string output; + encoder.Attach( new CryptoPP::StringSink( output ) ); + encoder.Put( digest, size ); + encoder.MessageEnd(); + + return output; +} |
