We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Remove password protection from ZIP without extracting the files


is there a way to remove a password protection from ZIP file without extracting them (password is knowing)?

We using the following code to encrypt a ZIP with a password:

                zipFileStream = File.Open(targetZipFile, FileMode.Create, FileAccess.ReadWrite,

                EncryptionSettings encryptionSettings = null;
                if (!string.IsNullOrWhiteSpace(password))
                    encryptionSettings = new AesEcryptionSettings(password, encryptionMethod);

                archive = new Archive(new ArchiveEntrySettings(encryptionSettings: encryptionSettings));
                foreach (var inputFile in inputFiles)
                    archive.CreateEntry(Path.GetFileName(inputFile), new FileInfo(inputFile), true);

Kind regards,

Hello @AStelzner,
No, it is impossible, but you can proceed without saving decrypted files to disk. Here is sample code:

using (var decrypted = new Archive())
    using (var encrypted = new Archive("encrypted.zip", new ArchiveLoadOptions(){DecryptionPassword = "p@s$"}))
         foreach (var encryptedEntry in encrypted.Entries)
             MemoryStream ms = new MemoryStream();
             decrypted.CreateEntry(encryptedEntry.Name, ms);

Please also note that Archive is IDisposable and should be disposed - in your code it is not within using block.

1 Like