Zip icon indicating copy to clipboard operation
Zip copied to clipboard

Zip with password not work.

Open pethanihiten opened this issue 4 years ago • 11 comments

we create one zip file with a password but we can't access it with a password. can you help to solve out?

pethanihiten avatar Feb 19 '21 12:02 pethanihiten

Same issue here ... seems to be a known issue, see #210.

Jeehut avatar Feb 23 '21 19:02 Jeehut

I have tested the code and it seems like it works fine, try this test.

func testZipWithPassword() throws {
        let imageURL1 = url(forResource: "3crBXeO", withExtension: "gif")!
        let sandboxFolder = try autoRemovingSandbox()
        let zipFilePath = sandboxFolder.appendingPathComponent("archive.zip")
        try Zip.zipFiles(paths: [imageURL1], zipFilePath: zipFilePath, password: "Images", progress: nil)
        XCTAssertTrue(FileManager.default.fileExists(atPath: zipFilePath.path))
        XCTAssertThrowsError(try Zip.unzipFile(zipFilePath, destination: sandboxFolder, overwrite: true, password: "Imagess", progress: nil))
        try Zip.unzipFile(zipFilePath, destination: sandboxFolder, overwrite: true, password: "Images", progress: nil)
        XCTAssertTrue(FileManager.default.fileExists(atPath: sandboxFolder.path))
    }

alrocha avatar Mar 19 '21 17:03 alrocha

Comfirmed the output zip file cannot be unzipped using BetterZip or builtin Archive Utility on latest macOS.

// run on physical iOS device
// package version: 2.1.0
try Zip.zipData(archiveFiles: archiveFiles, zipFilePath: fileUrl, password: "foobar", compression: .DefaultCompression, progress: nil)

However, the contents (filenames and modification dates) of the zip file can be displayed in BetterZip.

gongzhang avatar Mar 23 '21 05:03 gongzhang

Same issue here. Zip created with password can't be unzipped using the same password in macOS. However it can be unzipped using the unzip function by passing the password

kattaliraees avatar Apr 19 '22 11:04 kattaliraees

The same, however possible to use https://online.b1.org/online

evgzor avatar May 03 '22 15:05 evgzor

I am also having this issue with password protected archives; they can't be opened in macOS or Windows. Anyone know of any other Zip libraries? I tried using SSZipArchive but that also has issues.

stevenamani avatar Aug 11 '22 18:08 stevenamani

I am using b1 free archiver for unpacking... or 7.zip - very old version for windows

evgzor avatar Aug 11 '22 19:08 evgzor

I think it's the same issue as stated for #15 Zip uses AES-256 encryption by default. But Finder, the standard Apple unarchiver, and many unarchivers do not support AES-256. The archive should open just fine with something like The Unarchiver or Keka.

Edit: After seeing the comment from Natalia, I just generated another file and tried to uncompress it using The Unarchiver and Keka. Neither of them worked. But somehow iZip Unarchiver worked. So yeah, it may not be related to the encryption method.

startover205 avatar Jan 03 '23 17:01 startover205

@startover205 I tried to unarchive with The Unarchiver app, and it doesn't work correctly. However, I can't find the option to set there the encryption algorithm, only the encoding, so maybe that's the issue.

End effect with Apple unarchiver: prompts for password in a loop. End effect with The Unvarchiver app: accepts password, then claims it was incorrect for each file. However, creates the archive folder with all proper files inside, but all the files are empty. End effect with Keka app: prompts for password, claims it's invalid.

What is more, if I use Keka to compress a file using AES-256 with the same password and then try to uncompress it using Keka - it works. While for the same file compressed also with AES-256 with the same password via Zip framework it does not work. This leads me to the conclusion that the issue is NOT AES-256.

natalia-osa avatar Jan 16 '23 22:01 natalia-osa

Just unzipped a zipped file using same password used using "EncryptedZip2 for zip rar" available on AppStore mac

mawais91 avatar Jan 19 '24 19:01 mawais91

FYI. In my scenario, I prefer to have the option to restrict unzipping using any third-party software. When utilizing this library to zip a file, I aim for it to be exclusively unzip-able through this library. This adds an additional layer of complexity, particularly when dealing with secured files requiring a password for extraction. I acknowledge that this requirement has been raised as an issue, but I emphasize its importance as an optional feature.

waelsaad avatar Feb 22 '24 03:02 waelsaad