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