0 Introduction
To read this article, readers need to have the most basic knowledge of cryptography, such as symmetric and asymmetric encryption, digital signature, and so on. Fortunately, the preparation of this knowledge, one afternoon time is enough.
Many friends asked me how to use Cryptopp (the latest version is 5.4), I used to have no use, but always think it is a good thing, belong to one of the classic C + + library. Therefore, it is necessary to take it as one of the cornerstones of my software. I used to use the Windows Crypt API, ATL has the corresponding encapsulation class. However, after I encountered a problem, I decided to discard the crypt API. The reason is that I use Win2003 to encrypt things that fail to decrypt on the Win2000. It's very hot. Limited level, limited time, do not go into the deep search for reasons.
Switch to open source Cryptopp C + + library door, found that the use of Cryptopp strange, everywhere is a trap-like template, for me this on the cryptography itself scratch people, is undoubtedly worse. First time use, to fail and drubbing. However, Cryptopp in the industry's good reputation, so I could not bear to give up, after six months, I finally reread Cryptopp example, explore the use of methods. However, the direct use of cryptopp really very cumbersome, simply packaging as a DLL, I took it name: CryptoPP32.dll. Direct use of CryptoPP32.dll, do not need any cryptopp5.4 library, because I have cryptopp5.4 statically compiled into the.
I am at the following address:
Http://www.3snews.net/index.php/5890/action_viewspace_itemid_9580.html
Provides documentation downloads for the entire project, including cryptopp5.4, CryptoPP32, and test projects. The user must use VC7.1 to open the SLn file in the Cryptopp32_dll directory. For the first compilation, you must select Cryptlib in the build manager.
(I don't know how csdn upload files.) The download file that I provide can be freely distributed, reproduced, but may not change the author's statement. CSDN has many places to do is not friendly enough, hope to improve! Hope Csdn Blog Writing group to learn Http://www.3snews.net blog, than your strong many Ah! )
1 CryptoPP54 and CryptoPP32
The following are the methods for CryptoPP32.h interface files:
CryptoPP32.DLL interface method
...
Namespace CryptoPP32
{
BOOL Cryptopp32_dll Rsaes_oaep_generatekeys (const char *privfilename, const char *pubfilename, unsigned int keylength= , const char *seed=0);
BOOL Cryptopp32_dll Rsaes_oaep_generatekeys (string& strprivkey, string& strpubkey, unsigned int keyLength=512, const char *seed=0);
BOOL Cryptopp32_dll rsaes_oaep_encryptstring (const char *pubfilename, const char *message, string& cipher, const char *seed=0);
BOOL Cryptopp32_dll rsaes_oaep_decryptstring (const char *privfilename, const char *cipher, string& message);
BOOL Cryptopp32_dll rsaes_oaep_encryptstring (const string& strpubkey, const char *message, string& cipher, const Char *seed=0);
BOOL Cryptopp32_dll rsaes_oaep_decryptstring (const string& strprivkey, const char *cipher, string& Plain);
BOOL Cryptopp32_dll rsaes_oaep_encryptstring (const char* N, const char* E, const char* message, string& cipher, const char* seed=0);
BOOL Cryptopp32_dll rsaes_oaep_decryptstring (const char* N, const char* E, const char* D, const char* P, const char* Q, CO NST char* DP, const char* DQ, const char* U, const char* cipher, string& Plain);
BOOL Cryptopp32_dll Rsaes_pkcs_generatekeys (const char *privfilename, const char *pubfilename, unsigned int keylength= , const char *seed=0);
BOOL Cryptopp32_dll Rsaes_pkcs_generatekeys (string& strprivkey, string& strpubkey, unsigned int keyLength=512, const char *seed=0);
BOOL Cryptopp32_dll rsaes_pkcs_encryptstring (const char *pubfilename, const char *message, string& cipher, const char *seed=0);
BOOL Cryptopp32_dll rsaes_pkcs_encryptstring (const string& strpubkey, const char *message, string& cipher, const Char *seed=0);
BOOL Cryptopp32_dll rsaes_pkcs_decryptstring (const char *privfilename, const char *cipher, string& message);
BOOL Cryptopp32_dll rsaes_pkcs_decryptstring (const string& strprivkey, const char *cipher, string& Plain);
BOOL Cryptopp32_dll rsaes_pkcs_encryptstring (const char* N, const char* E, const char* message, string& cipher, const char* seed=0);
BOOL Cryptopp32_dll rsaes_pkcs_decryptstring (const char* N, const char* E, const char* D, const char* P, const char* Q, CO NST char* DP, const char* DQ, const char* U, const char* cipher, string& Plain);
BOOL Cryptopp32_dll rsass_pkcs_sign (const char *privfilename, const char *msgfilename, const char *signfilename, const CHA R *hashfunc= "SHA");
BOOL Cryptopp32_dll rsass_pkcs_verify (const char *pubfilename, const char *msgfilename, const char *signfilename, const CH Ar *hashfunc= "SHA");
BOOL Cryptopp32_dll rsass_pkcs_sign (const string& strprivkey, const char *message, string& signature, const char * Hashfunc= "SHA");
BOOL Cryptopp32_dll rsass_pkcs_verify (const string& strpubkey, const char *message, const string& signature, cons T char *hashfunc= "SHA");
BOOL Cryptopp32_dll hmac_sha1_encryptstring (const char *instring, const char *passphrase, string& outstring);
BOOL Cryptopp32_dll hmac_sha1_decryptstring (const char *instring, const char *passphrase, string& outstring);
BOOL Cryptopp32_dll hmac_sha1_encryptfile (const char *infilename, const char *outfilename, const char *passphrase);
BOOL Cryptopp32_dll hmac_sha1_decryptfile (const char *infilename, const char *outfilename, const char *passphrase);
BOOL Cryptopp32_dll gzipfile (const char *infilename, const char *outfilename, int deflatelevel);
BOOL Cryptopp32_dll gunzipfile (const char *infilename, const char *outfilename);
BOOL Cryptopp32_dll base64encode (const char *infilename, const char *outfilename);
BOOL Cryptopp32_dll base64decode (const char *infilename, const char *outfilename);
BOOL Cryptopp32_dll base64encode (const char *plain, string& encoded);
BOOL Cryptopp32_dll base64decode (const char *encoded, string& Plain);
BOOL Cryptopp32_dll hexencode (const char *infilename, const char *outfilename);
BOOL Cryptopp32_dll hexdecode (const char *infilename, const char *outfilename);
BOOL Cryptopp32_dll hexencode (const char *plain, string& encoded);
BOOL Cryptopp32_dll hexdecode (const char *encoded, string& Plain);
};