|  |  |  | @ -23,52 +23,60 @@ RH_Encryption::RH_Encryption(){ | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string (string)> RH_Encryption::md5(){ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     return [] (string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         const char* stringValue = value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |     function<string (string)> methode = [] (string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         const unsigned char* stringValue = (unsigned char *) value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |         MD5_CTX md5; | 
			
		
	
		
			
				
					|  |  |  |  |         MD5_Init(&md5); | 
			
		
	
		
			
				
					|  |  |  |  |         MD5_Update(&md5,(const unsigned char*)stringValue, value.length()); | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[16]; | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[MD5_DIGEST_LENGTH]; | 
			
		
	
		
			
				
					|  |  |  |  |         MD5_Final(buffer, &md5); | 
			
		
	
		
			
				
					|  |  |  |  |         char mdString[32]; | 
			
		
	
		
			
				
					|  |  |  |  |         string result; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         for (uint16_t i = 0; i < 16; i++) { | 
			
		
	
		
			
				
					|  |  |  |  |             sprintf(mdString, "%02x", buffer[i]); | 
			
		
	
		
			
				
					|  |  |  |  |             result.append(mdString); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return result; | 
			
		
	
		
			
				
					|  |  |  |  |         return  bytesArrayToStrinctString(MD5_DIGEST_LENGTH,buffer); | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  |     return methode; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string (string)> RH_Encryption::sha1(){ | 
			
		
	
		
			
				
					|  |  |  |  |     return [](string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         return value; | 
			
		
	
		
			
				
					|  |  |  |  |         const unsigned char* stringValue = (unsigned char *) value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[SHA_DIGEST_LENGTH]; | 
			
		
	
		
			
				
					|  |  |  |  |         SHA(stringValue,value.length(),buffer); | 
			
		
	
		
			
				
					|  |  |  |  |         return bytesArrayToStrinctString(SHA_DIGEST_LENGTH,buffer); | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string (string)> RH_Encryption::sha224(){ | 
			
		
	
		
			
				
					|  |  |  |  |     return [](string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         return value; | 
			
		
	
		
			
				
					|  |  |  |  |         const unsigned char* stringValue = (unsigned char *) value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[SHA224_DIGEST_LENGTH]; | 
			
		
	
		
			
				
					|  |  |  |  |         SHA224(stringValue,value.length(),buffer); | 
			
		
	
		
			
				
					|  |  |  |  |         return bytesArrayToStrinctString(SHA224_DIGEST_LENGTH,buffer); | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string (string)> RH_Encryption::sha384(){ | 
			
		
	
		
			
				
					|  |  |  |  |     return [](string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         return value; | 
			
		
	
		
			
				
					|  |  |  |  |         const unsigned char* stringValue = (unsigned char *) value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[SHA384_DIGEST_LENGTH]; | 
			
		
	
		
			
				
					|  |  |  |  |         SHA384(stringValue,value.length(),buffer); | 
			
		
	
		
			
				
					|  |  |  |  |         return bytesArrayToStrinctString(SHA384_DIGEST_LENGTH,buffer); | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string (string)> RH_Encryption::sha256(){ | 
			
		
	
		
			
				
					|  |  |  |  |     return [](string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         return value; | 
			
		
	
		
			
				
					|  |  |  |  |         const unsigned char* stringValue = (unsigned char *) value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[SHA256_DIGEST_LENGTH]; | 
			
		
	
		
			
				
					|  |  |  |  |         SHA256(stringValue,value.length(),buffer); | 
			
		
	
		
			
				
					|  |  |  |  |         return bytesArrayToStrinctString(SHA256_DIGEST_LENGTH,buffer); | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string (string)> RH_Encryption::sha512( ){ | 
			
		
	
		
			
				
					|  |  |  |  |     return [](string value){ | 
			
		
	
		
			
				
					|  |  |  |  |         return value; | 
			
		
	
		
			
				
					|  |  |  |  |         const unsigned char* stringValue = (unsigned char *) value.c_str(); | 
			
		
	
		
			
				
					|  |  |  |  |         unsigned char buffer[SHA512_DIGEST_LENGTH]; | 
			
		
	
		
			
				
					|  |  |  |  |         SHA256(stringValue,value.length(),buffer); | 
			
		
	
		
			
				
					|  |  |  |  |         return bytesArrayToStrinctString(SHA512_DIGEST_LENGTH,buffer); | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -78,10 +86,34 @@ function<string (string)> RH_Encryption::none(){ | 
			
		
	
		
			
				
					|  |  |  |  |     }; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function<string(string)> RH_Encryption::getFunctionHashLambda(string hashMethode) { | 
			
		
	
		
			
				
					|  |  |  |  |     function<string(string)> resultMethode; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     if (hashMethode == "md5")           resultMethode = md5(); | 
			
		
	
		
			
				
					|  |  |  |  |     else if(hashMethode == "sha1")      resultMethode = sha1(); | 
			
		
	
		
			
				
					|  |  |  |  |     else if(hashMethode == "sha224")    resultMethode = sha224(); | 
			
		
	
		
			
				
					|  |  |  |  |     else if(hashMethode == "sha384")    resultMethode = sha384(); | 
			
		
	
		
			
				
					|  |  |  |  |     else if(hashMethode == "sha256")    resultMethode = sha256(); | 
			
		
	
		
			
				
					|  |  |  |  |     else if(hashMethode == "sha512")    resultMethode = sha512(); | 
			
		
	
		
			
				
					|  |  |  |  |     else                                resultMethode = none(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     return resultMethode; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | /*function<string (string)> RH_Encryption::hashForLambda(function<string(string)> functionLambda, string value){
 | 
			
		
	
		
			
				
					|  |  |  |  |     return functionLambda(value); | 
			
		
	
		
			
				
					|  |  |  |  | }*/ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | string RH_Encryption::bytesArrayToStrinctString(uint8_t lenght, unsigned char * bytes) { | 
			
		
	
		
			
				
					|  |  |  |  |     char resString[2]; | 
			
		
	
		
			
				
					|  |  |  |  |     string result; | 
			
		
	
		
			
				
					|  |  |  |  |     for (uint8_t i = 0; i < lenght; i++){ | 
			
		
	
		
			
				
					|  |  |  |  |         sprintf(resString,"%02x", bytes[i]); | 
			
		
	
		
			
				
					|  |  |  |  |         result.append(resString); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |     return result; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | RH_Encryption::~RH_Encryption(){ | 
			
		
	
	
		
			
				
					|  |  |  | 
 |