While Delphi 12 supports ZIP encryption, the actual encryption algorithm has to be provided by the developer itself or a library implementing the new IZipCryptor interface.
For the common PKWARE Zip 2.0 encryption (see APPNOTE.TXT) an implementation can be found in PKWAREZipCryptor.pas. The usage is shown in the following example, which extracts all files from an encrypted zip file:
var
bytes: TBytes;
fileName: string;
zipFile: TZipFile;
begin
zipFile := TZipFile.Create;
try
zipFile.Cryptor := TPKWAREZipCryptor.Create;
zipFile.Password := cPassword;
zipFile.Open(zipFileName, zmRead);
for var I := 0 to zipfile.FileCount - 1 do begin
fileName := zipFile.FileNames[I];
zipFile.Read(I, bytes);
TFile.WriteAllBytes(fileName, bytes);
end;
zipFile.Close;
finally
zipFile.Free;
end;
end;