The blob to be converted.
void main()
{
//First of all we need a string to encrypt
BYTE szTest[256] = "this string is for testing purposes";
//DataIn is for the unencrypted string and DataOut for the encrypted data.
DATA_BLOB DataIn = {0};
DATA_BLOB DataOut = {0};
//Convert the string to a pointer.
BYTE *pbDataInput = (BYTE *)szTest;
//Set pbData to the input string and specify how much memory it is using.
DataIn.pbData = pbDataInput;
DataIn.cbData = (DWORD) strlen((char *) pbDataInput) + 1;
//This will encrypt DataIn using CryptProtectData and save the result in DataOut.
//CryptProtectData encrypted data is only decryptable on the same computer as it was encrypted on.
EncryptData(&DataIn, &DataOut);
//Declaration of the recieving string.
char *szOut = new char[(DataOut.cbData * 2) + 1];
//Converts the content of DataOut to a string and saves it in szOut.
BlobToStr(&DataOut, szOut);
//Do something with the string here.
//Free the memory to prevent memory leaks.
LocalFree(DataOut.pbData);
delete szOut;
}