Open hai-nguyen-trung opened 3 years ago
Sorry, it because I zip encrypted with an empty text file. If the file has value then it's working fine. But it's expecting it will require the password even if it's an empty file, isn't it?
But it's expecting it will require the password even if it's an empty file, isn't it?
Maybe it depends on how you unzip the file (in other words, it depends on the unzip application), I think. 🤔
How did you unzip the file?
I checked that on macOS and unzip
asked me to input password even if the file inside the zip file is empty.
Here is my procedure:
var fs = require('fs');
var archiver = require('archiver');
archiver.registerFormat('zip-encryptable', require('archiver-zip-encryptable'));
var output = fs.createWriteStream(__dirname + '/example.zip');
var archive = archiver('zip-encryptable', {
zlib: { level: 9 },
forceLocalTime: true,
password: 'test'
});
archive.pipe(output);
archive.append(Buffer.from(''), { name: 'test.txt' });
archive.finalize();
❯ node index.js
❯ zipinfo example.zip
Archive: example.zip
Zip file size: 142 bytes, number of entries: 1
-rw-r--r-- 4.5 unx 0 Bl stor 21-Jul-13 23:42 test.txt
1 file, 0 bytes uncompressed, 0 bytes compressed: 0.0%
❯ unzip example.zip
Archive: example.zip
[example.zip] test.txt password:
password incorrect--reenter:
password incorrect--reenter:
skipping: test.txt incorrect password
FYI. Even if the target file is empty, there is data named "encryption header" in the encrypted zip file and applications to unzip should be able to validate password with that.
Please see "6.1 Traditional PKWARE Decryption" section in https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT for details.
I tried to use the example to zip files with the password
test
but can unzip without any password input. Please help to check. Thanks.