1

I have a Delphi project in which a zip file which is password protected is created on some user action. In order to do this we have used a third party component abbrevia. But I now want to do this through Delphi native component using system.zip unit.

procedure CreateZip( zipfilename : string);
var
  Zipper : TZipFile;
begin
  Zipper := TZipFile.Create;
  Zipper.Open( zipfilename + '.zip',zmWrite);
  Zipper.Add('filename1.txt','',zcDeflate);
  Zipper.Add('filename2.txt','',zcDeflate);
  Zipper.Add('filename3.txt','',zcDeflate);
  Zipper.Free;
end;

This creates a zip file with the name passed as a parameter to the procedure. But I want the generated zip to be password protected. Any help would be appreciated.

akash_27
  • 151
  • 1
  • 9
  • It's nice to want it, but it seems you're out of luck (password protected compression doesn't seem to be supported by `TZipFile`). – TLama Aug 20 '14 at 09:23
  • @TLama- Any way of achieving this through Delphi native only. – akash_27 Aug 20 '14 at 09:30
  • Yes, e.g. if you extend `TZipFile` to support password protected compression (since `TZipFile` is the only class for ZIP compression shipped with Delphi). I would personally stay with Abbrevia. – TLama Aug 20 '14 at 09:40
  • try a freeware library from here https://github.com/AlexanderBagel/FWZip, it support setting password for zip archives and more features for zip – kutsoff Aug 20 '14 at 10:03
  • @TLama -You mean to say I need to extend TZipFile unit and write my own password protection code on it. – akash_27 Aug 20 '14 at 10:21
  • Yup, that's what I meant. – TLama Aug 20 '14 at 10:23
  • Note, that "old" or "common" password protection in ZIP is weak. WinZIP and PKWare both introduced their secure extensions (incompatible with each other), so you'll have lots of work to do. Our SecureBlackbox supports all those extensions BTW. – Eugene Mayevski 'Callback Aug 20 '14 at 10:40
  • @EugeneMayevski'EldoSCorp- Thanks for your comment.I will keep this in mind and try solving my problem. – akash_27 Aug 20 '14 at 10:51

0 Answers0