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


About Uwe Raabe

Addicted to Pascal/Delphi since the late 70's
This entry was posted in Delphi, Programming. Bookmark the permalink.

6 Responses to TZipFile with Password Encryption (Part 3)

  1. hflick1105 says:

    Did you create a report in Quality Portal?

    • Uwe Raabe says:

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

      • Remy Lebeau says:

        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.

  2. mvanrijnen says:

    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.

  3. Have you tried to access zip using your unit from a password project zip created in say WinRAR?

Comments are closed.