Encrypting and Decrypting Data with the CryptoAPI
By Paula Tomlinson, January 01, 2002
The CryptoAPI seems quite complicated, but by just using a handful of the simpler routines and default parameters you can do some very useful things, such as hashing data and encrypting and decrypting data.
January 2002/Systems Insider
Listing 1: crypto.h
The definition of the CMyCrypto class
// crypto.h
class CMyCrypto {
public:
CMyCrypto(LPTSTR lpPassword, ALG_ID algorithm);
~CMyCrypto();
BOOL Encrypt(LPBYTE pData, LPDWORD pdwDataSize,
DWORD dwBufferSize, BOOL bFinal);
BOOL Decrypt(LPBYTE pData, LPDWORD dwDataSize,
BOOL bFinal);
private:
HCRYPTPROV m_hProv;
HCRYPTKEY m_hKey;
};