I am a novice in C++ and started learning wincrypt yesterday. I have written this piece of code,
#pragma comment(lib, "crypt32.lib")
#include <iostream>
#include <windows.h>
#include <wincrypt.h> // CryptoAPI definitions
using namespace std;
int main()
{
string encMe = "password";
HCRYPTKEY hKey;
HCRYPTPROV hProv;
PBYTE pbBuffer = NULL;
CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_NEWKEYSET | CRYPT_VERIFYCONTEXT);
//cout << hex << GetLastError() << endl; DEBUG
if(NTE_EXISTS == GetLastError())
{
CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT);
}
else if(0 == GetLastError())
{
cout << "Succes1" << endl;
}
CryptGenKey(hProv, CALG_AES_256, CRYPT_EXPORTABLE, &hKey);
if(GetLastError() == 0)
{
cout << "Succes2" << endl;
cout << hKey << endl;
}
cout << CryptEncrypt(hKey, 0, TRUE, 0, NULL, NULL, 1000) << endl;
cout << GetLastError();
}
and I am stuck on the CryptEncrypt function. I read the MSDN page and have not understood anything after "hKey, 0, True, 0". Explain me for example what a 'A pointer to a buffer that contains the plaintext to be encrypted' is. Thank you in advance!