The second parameter requires a pointer to LPWSTR which can be set to NULL:
1 2 3 4 5 6 7 8 9 10 11
LPWSTR pDescrOut = NULL;
//--------------------------------------------------------------------
// The buffer DataOut would be created using the CryptProtectData
// function. If may have been read in from a file.
//--------------------------------------------------------------------
// Begin unprotect phase.
if (CryptUnprotectData(
&DataOut,
&pDescrOut,
No,line is encrypted. I need to decrypt it. I read a file and store it in std::string line; and then
i pass line variable to std::string Database::Decrypt(std::string line) that should return the decrypted line
Well, the decryption fails if a single byte is wrong. So I'm surprised that the encrypted data is a string. How did the string get the data? Does the terminating 0 belong to the encrypted data?
Make sure that each and every byte (not more not less) from the encryption is passed to the decryption.
By the way: line 17/18 are wrong. ClearText and EncryptedData are not dynamically allocated hence you shouldn't use LocalFree.
while ClearText.pbData should be used with LocalFree