<pre>#include <stdio.h> #include <windows.h> #include <Wincrypt.h> #include <string> #include <vector> #include <fstream> #include <iostream> using namespace std; #define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING) #pragma comment (lib, "Crypt32.lib") int main() { string data = ("data I want to decode \n"); cout << data; LPWSTR pDescrOut = NULL; DATA_BLOB DataBytes; BYTE* pbDataOutput = (BYTE*)data.data(); DWORD cbDataOutput = strlen((char*)pbDataOutput) + 1; DataBytes.pbData = pbDataOutput; DataBytes.cbData = cbDataOutput; HRESULT res = CryptUnprotectData( &DataBytes, NULL, NULL, // Optional entropy NULL, // Reserved NULL, // Here, the optional // prompt structure is not // used. 0, &DataBytes); printf("The decrypted data is: %s\n", DataBytes.pbData); LocalFree(pDescrOut); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)