Jump to content
Mark Williams

TEncryptedZipFile

Recommended Posts

@Uwe Raabe 

I have just had a look at this component on your blog. 

I could get it to write an encrypted zip file, which I can open manually no problem, but I cannot get it to decrypt using the component. 

I downloaded the amended unit from https://www.uweraabe.de/Blog/2017/05/07/tzipfile-with-password-encryption-part-3/, but this still didn't work for me.

 

My code for unzipping is as follows:

 

Zipper:=TEncryptedZipFile.Create('Mark');
Stream:=TMemoryStream.create;
try
  DecompressionStream:=TStream.Create;
  Zipper.Open(OpenDialog1.filename, zmReadWrite);
  Zipper.Read('File', DecompressionStream, zh);      
  Stream.CopyFrom(DecompressionStream, DecompressionStream.size); {Crashes here}
  DecompressionStream.Free;
  Stream.Position:=0;
  Stream.SaveToFile(ExtractFilePath(includeTrailingPathDelimiter(openDialog1.FileName))+'File.docx');
  Zipper.Close;
finally
  zipper.Free;
  stream.Free;
end;

I have used the same routine as I would for reading from the standard TZipFile ie using the DecompressionStream. Can't work out whether my approach is write or if there is a problem with the TEncryptedZipFile code.

 

Anyways my debug output is:

System.Classes TStream.ReadBuffer
System.Classes     8340   +1 TStream.ReadBuffer
uEncryptedZipFile   299   +9 TDecryptStream.Skip
uEncryptedZipFile   277  +10 TDecryptStream.Seek
System.Classes     7561   +1 TStream.SetPosition
System.ZLib        2891  +32 TZDecompressionStream.Read
System.ZLib        2939  +27 TZDecompressionStream.Seek
System.Classes     7569   +2 TStream.GetSize

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×