From 77affb6d5564f691ea337a3971fdc85f2460ed92 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sat, 21 Mar 2015 06:55:46 +0100 Subject: Make untracked folder --- Untracked/Doxygen/CryptClass/HASHCrypt.hpp | 99 ++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Untracked/Doxygen/CryptClass/HASHCrypt.hpp (limited to 'Untracked/Doxygen/CryptClass/HASHCrypt.hpp') diff --git a/Untracked/Doxygen/CryptClass/HASHCrypt.hpp b/Untracked/Doxygen/CryptClass/HASHCrypt.hpp new file mode 100644 index 0000000..22e0c4f --- /dev/null +++ b/Untracked/Doxygen/CryptClass/HASHCrypt.hpp @@ -0,0 +1,99 @@ +/** + * @file HASHCrypt.hpp + * @brief HASHCrypt class header + * @author manzerbredes + * @date 8 Mars 2015 + * + * Contain all prototypes of HASHCrypt class. + * + */ + + +//----- std ----- +#include +#include +#include + +//----- crypto++ ----- +#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 +#include //For MD5 +#include //For Hex convertion +#include //For SHA +#include + + +/** + * @class HASHCrypt HASHCrypt.hpp "/CryptClass/HASHCrypt.hpp" + * @brief Hashing class + * @author manzerbredes + * + * Class who handle hashing functions to a byte* parameter. + * HASHCrypt try to detect errors and throw exceptions. + * HASHCrypt use crypto++ library. + */ +class HASHCrypt{ + + public: + /** + * @brief Contructor + */ + HASHCrypt(); + + /** + * @brief Destructor + */ + ~HASHCrypt(); + + /** + * @brief Create an MD5 over 128 bits on a digest array of bytes. + * + * @param chain : Chain to hash + * @param digest : An array of bytes (8 bits) + * @param size : Length of the array digest + * + * **Warning** digest will be modified. + * Digest must be an array of byte with 16 entries + */ + void getMD5_128(std::string chain, byte* digest, int size); + + /** + * @brief Create an SHA over 256 bits on a digest array of bytes. + * + * @param chain : Chain to hash + * @param digest : An array of bytes (8 bits) + * @param size : Length of the array digest + * + * **Warning** digest will be modified. + * Digest must be an array of byte with 32 entries + */ + void getSHA_256(std::string chain, byte* digest, int size); //Retourne SHA_256 + + private: + + /** + * @brief Check the digest size + * + * @param sizeRequired : Digest size expected + * @param size : Given digest size + * + * Throw an exception, and stop the programm if + * sizeRequired != size + * Use getInvalidDigestSizeError method. + */ + void checkDigestSize(int sizeRequired, int size); + + /** + * @brief Make and error message. + * + * @param sizeRequired : Digest size expected + * @param size : Given digest size + * + * @return a string correspond to the error message + * + * Construct an error message with sizeRequired and size. + */ + std::string getInvalidDigestSizeError(int sizeRequired, int size); + + + +}; -- cgit v1.2.3