brendan-duncan/archive

Unzip password protected zip is not working

Opened this issue · 4 comments

I am trying to unzip a file size of about 30 MB containing txt and mp3 files but it is not working when zip has password. It actually unzips file no matter what password is but these files would be corrupted.

I tried to zip all files inside without password and unzip worked this time. So I think issue is about unzipping with password. My code block:

  final stream = InputFileStream('$filePath/$baseName');
  Archive archive =
      ZipDecoder().decodeBuffer(stream, password: "password");

  for (ArchiveFile file in archive) {
    print("file:${file.name}");
    print("size:${(file.size / 1024).ceil()}K");
    print(file.content.toString());
    if (file.isFile) {
      File outFile = File('$filePath/out/${file.name}');
      outFile = await outFile.create(recursive: true);
      await outFile.writeAsBytes(file.content);
    } else {
      Directory('$filePath/out/${file.name}').create(recursive: true);
    }
  }

PS: I also tried to decodebytes. It is not working either.

I have same issue. I noticed that when the zip has a password, the files are extracted but compressed.
Any news here, @brendan-duncan?

I'll need to implement the proper decryption method, I think I only ever implemented the basic password decryption. I'll try and find some time to do that, since it keeps coming up.

I just released 3.3.3 that fixed a problem causing decryption to not work. It only supports the ZipCrypto format currently, not AES. I am in the process of trying to write AES decryption, but it's slow going due to time constraints.

That's great. Thanks for your effort.