2023年12月30日发(作者:)

#ifndef _CRYPTOTEST_H_#define _CRYPTOTEST_H_#include using namespace std;typedef enum { GENERAL = 0, ECB, CBC, CFB, OFB, TRIPLE_ECB, TRIPLE_CBC}CRYPTO_MODE;string DES_Encrypt(const string cleartext, const string key, CRYPTO_MODE mode);string DES_Decrypt(const string ciphertext, const string key, CRYPTO_MODE mode);string RC4_Encrypt(const string cleartext, const string key);string RC4_Decrypt(const string ciphertext, const string key);string MD5_Digest(const string cleartext);#endif //_CRYPTOTEST_H_:

#include "stdafx.h"#include #include #include #include #include #include #include #include "cryptotest.h"using namespace std;string MD5_Digest(const string cleartext){ string strDigest; unsigned char tmp[16] = {0};#if 0 MD5((const unsigned char*)cleartext.c_str(), (), tmp);#else MD5_CTX c; MD5_Init(&c); MD5_Update(&c, cleartext.c_str(), ()); MD5_Final(tmp, &c);#endif char* tmp1 = new char[32 + 1]; memset(tmp1, 0, 32 + 1); for(int i = 0; i < 16; i++)

sprintf(&(tmp1[i*2]), "%02x", tmp[i]); //cout<

strDigest = (char*)tmp1; delete [] tmp1; return strDigest;}: