TZipFile with Password Encryption (Part 3)

In the comments of the last blog post about encrypted zip files several people encountered problems with zip files encrypted with the shown sources. Well, I have to apologize: this actually cannot work with the sources provided due to some suboptimal behavior of TZipFile. Its current implementation calculates the CRC32 value after encrypting the data. For that the CRC32 value used for encryption is simply incorrect.

The reason why this slipped through is damn simple: As my first approach was implementing this feature in the original sources, I changed this right in the beginning and later forgot about it completely when moving this feature into a derived class. Thus my tests succeeded just because they still used the manipulated version of System.Zip.

It turned out that getting the correct CRC32 value for encryption without changing the original source was anything but easy. For the sake of providing at least one solution in a timely manner, I opted for sacrificing performance and memory considerations, which can surely be optimized in a later approach. As a benefit the current solution also closes a memory leak present in the previous version.

The new version can be downloaded here:  EncryptedZipFile


Author: Uwe Raabe

Addicted to Pascal/Delphi since the late 70's

6 thoughts on “TZipFile with Password Encryption (Part 3)”

    1. Not yet. I am struggling between a QP report or sending them a complete overhaul of TZipFile with my extensions already incorporated.

      1. You can attach files to QP reports. So go ahead and file the report, explain the issues, and include the complete overhaul as a workaround.

  1. be carefull with large files and TZipfile, i put a bug already more than a year ago.
    When zipping large files, no error, no exceptions but not able to unzip or so.

    1. I am aware of that. TZipFile has plenty of room for improvement.

Comments are closed.