cthackers / adm-zip

A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk
MIT License
2.05k stars 375 forks source link

Can not unzip file with password #467

Open mqliutie opened 10 months ago

mqliutie commented 10 months ago
import archiver from 'archiver';

archiver.registerFormat('zip-encrypted', require('archiver-zip-encrypted'));

const archive = archiver.create('zip-encrypted', {
  zlib: { level: 8 },
  encryptionMethod: 'aes256',
  password: 'n.ddsadc3ch',
});
const entry = path.join(process.cwd(), 'app/dist/sourcemaps');
const output = fs.createWriteStream(path.join(process.cwd(), 'app/dist/sourcemaps.zip'));
archive.pipe(output);
archive.directory(entry, 'sourcemaps');
archive.finalize();

Above codes show how can I zip files with password

I want to unzip this file named sourcemaps.zip. I used unzipper and adm-zip. all of them tell me the password 'n.ddsadc3ch' is bad password. but I can use it unzip this file on Finder macOS. so How can i unzip this file?

lukemalcolm commented 8 months ago

@mqliutie Give this a go with 0.5.12 (which includes pull #472) and see if the issue is now resolved.

KurtMar commented 8 months ago

@lukemalcolm I tested the latest adm-zip@0.5.12, but was unable to decrypt AES265 Deflate. https://www.npmjs.com/package/@zip.js/zip.js does work. Do you have any idea why this would be the case? Is it @cthackers in fact so that adm-zip does not support AES at all?

lukemalcolm commented 8 months ago

@KurtMar As far as I'm aware, adm-zip does not support AES decryption, only ZipCrypto method.