I want to encrypt a file with AES CBC mode
encryption, Using cryptoAPI
functions and set my own key from the command-line (It my change in the code)
I imagine that the key (after change) will be 1a1dc91c907325c6
and tried in this form:
HCRYPTPROV hProv = NULL;
HCRYPTKEY hKey = NULL;
DWORD dwBlobLen;
PBYTE pbKeyBlob = NULL;
pbKeyBlob = (PBYTE)"1a1dc91c907325c6";
if(!CryptAcquireContext(&hProv, NULL,NULL, PROV_RSA_AES,CRYPT_VERIFYCONTEXT))
{
printf(" Error in AcquireContext 0x%08x \n",GetLastError());
}
if (!CryptImportKey(hProv,pbKeyBlob,sizeof(pbKeyBlob),0,CRYPT_EXPORTABLE,&hKey ))
{
printf("Error 0x%08x in importing the Des key \n",GetLastError());
}
but CryptImportKey
failed
I don't know how to use cryptoAPI functions and It's parameters
I tested some other codes and change the parameters or function's call's order for about 2 weeks but I wasn't able to do this
Please help me [a big help :)]
Thank you