PeterPanettone 157 Posted December 16, 2023 It seems that the Delphi RTL now supports ZIP encryption in Delphi 12? Does anyone have an example code that shows how to extract a file from an encrypted ZIP file using the Delphi 12 RTL? Share this post Link to post
Uwe Raabe 2057 Posted December 16, 2023 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; 3 3 Share this post Link to post