Skip to content

Decryption method not supported error when remove existing zip-entry and add new zip-entry with same name in zip file. #414

@madanbhangre

Description

@madanbhangre

I am using SharpZipLib v1.2.0.246 to zip and unzip the files with AES encryption.

Steps to reproduce

  1. I have set the zipEntry.AESKeySize to 128 or 256
  2. I have a zip file which contains a zip-entry i.e. 'Test.xml' file which i reads during initialization.
  3. The Test.xml file contents is getting updated and i have to update the zip file accordingly.
  4. To do this firstly i am removing the 'Test.xml' from zip(deleting the file) and add new entry with same name using StaticDataSource.
  5. While doing this, the version of zip-entry is getting changed. i.e. when zip file is got created the version of zip entry was '51' but after deleting and adding new entry it became '20'. so i got the "Decryption method not supported, at ICSharpCode.SharpZipLib.Zip.ZipFile.CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry) in 'zipfilepath' "

Expected behavior

It should update zipfile with latest zip entry and should be AES encrypted.

Actual behavior

It throws exception :
ICSharpCode.SharpZipLib.Zip.ZipException: 'Decryption method not supported
at ICSharpCode.SharpZipLib.Zip.ZipFile.CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry) in C:\projects\sharpziplib\src\ICSharpCode.SharpZipLib\Zip\ZipFile.cs:line 3606
at ICSharpCode.SharpZipLib.Zip.ZipFile.GetInputStream(Int64 entryIndex) in C:\projects\sharpziplib\src\ICSharpCode.SharpZipLib\Zip\ZipFile.cs:line 867
at ICSharpCode.SharpZipLib.Zip.ZipFile.GetInputStream(ZipEntry entry) in C:\projects\sharpziplib\src\ICSharpCode.SharpZipLib\Zip\ZipFile.cs:line 835
at Knorr.DF.Zip.KBZipContainer.ExtractZipEntries(Stream str, String password, Int32 aesKeySize)

Version of SharpZipLib

ICSharpCode.SharpZipLib v1.2.0.246

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions