Using Delphi 10.2.3
Win32 Compiling
Latest Crypto Pack as of today. 4.3.1.0
AESEncryption.DecryptFileW seems to work with what I have.
AESEncryption.Decrypt to do same data via A string, returns a blank string. No error.
I made a small routine to do this and this works, using the DecryptStream and TStringStreams....
function DecryptString(s: string; aes: TAESEncryption): string;
var
stream1, stream2: TStringStream;
begin
stream1 := TStringStream.Create;
stream1.Position := 0;
stream1.WriteString(s);
stream2 := TStringStream.Create;
aes.DecryptStream(stream1, TStream(stream2));
Result := stream2.DataString;
stream1.Free;
stream2.Free;
end;
....
var
eStr : String;
dStr : String;
...
AESEncryption := TAESEncryption.Create(nil);
AESEncryption.AType := atCBC;
AESEncryption.IVMode := userdefined;
AESEncryption.keyLength := kl256;
AESEncryption.IV := HexToString(strIVHex);
AESEncryption.key := HexToString(strKeyHex);
AESEncryption.Unicode := TUnicode.noUni;
AESEncryption.paddingMode := PKCS7;
AESEncryption.outputFormat := raw;
eStr := tfile.ReadAllText(inputFIle, tencoding.ANSI);
dStr := DecryptString(eStr, AESEncryption); // <-- my flavor using string streams
// dStr := AESEncryption.Decrypt(eStr); // <---- this won't work. dSTR is blank. reported to TMS.
Memo2.text := dStr;
AESEncryption.Free;
I will eventually not get a file, but a dump of the AES-256-CBC data from a stored procedure call.
And need to decrypt it on the fly.
My DecryptString call works, but wondering if this is a bug or am I missing something?