0
const unzipper = require("unzipper");
const fs = require("fs-extra");

async function test() {
  const file = "old.zip";
  const password = "abc";
  const directory = await unzipper.Open.file(file);
  console.log("password", password);
  const extracted = await directory.files[0].buffer(password);
  fs.writeFileSync("extracted/", extracted);
}
test();

I have two files, old.zip and new.zip. The only difference is that when I created old zip using winrar, I checked legacy encryption. You can see the picture below.

enter image description here

My code works for old zip, but not new.zip. Is there any other way to extract the new.zip file?

edit: change title from using javascript => in Node js

ddeark
  • 13
  • 3
  • Does this answer your question? [Unzipping a password protected file in Node.js](https://stackoverflow.com/questions/23926927/unzipping-a-password-protected-file-in-node-js) – Vukky Nov 08 '21 at 08:03
  • @Vukky apparently not. unzip has some issue with node 12, see https://github.com/EvanOxfeld/node-unzip/issues/122. and using unzipper didnt help since it only works on legacy encrypted zip – ddeark Nov 09 '21 at 02:53

0 Answers0