I need to be able to decrypt the file created by this line of code:
openssl enc -e -aes256 -a -pass pass:xxxx -in *.zip -out *.cad
and also be able to encrypt a file in a similar manner.
Google tells me we can do OpenSSl in Delphi.
Can you point me to where I start looking?
I asked ChatGPT how to do it and it came back with the following code. I haven’t tested it so it may or may not work - but hopefully it should give to a place to start.
IdHash, IdHashMessageDigest, System.Classes, IdCipher;
procedure DecryptFile(const InFile, OutFile, Password: string);
InStream, OutStream: TFileStream;
Hash := TIdHashMessageDigest5.Create;
Key := Hash.HashStringAsBytes(Password);
Cipher := TIdCipher.Create(nil);
Cipher.CipherId := 'aes-256-cbc';
Cipher.Mode := cmCBC;
Cipher.Password := BytesToString(Key);
InStream := TFileStream.Create(InFile, fmOpenRead);
OutStream := TFileStream.Create(OutFile, fmCreate);
Cipher.DecryptStream(InStream, OutStream, InStream.Size);
I wonder if it’s plucking example from the Web.