我使用 zip4j 压缩某些文件。它能够正确压缩,并且在提取时也要求输入密码。到此为止吧。现在我面临的问题
- 用密码加密后,用7zip打开就可以看到文件名【有什么办法可以解决这个问题?】
- 您可以将新文件添加到 zip 中,只需通过 7zip 打开它并拖动将添加的新文件,并允许特别提取该文件而无需密码。[需要禁用这个吗?]
我的要求是锁定一些文件,用户不应该能够使用 zip 进行操作。(第1点也可以忽略)
我还有其他的吗?
final ZipFile zipFile = new ZipFile(outputFile);
final ArrayList filesToAdd = new ArrayList();
for (final String file : fileList) {
filesToAdd.add(new File(file));
}
// Initiate Zip Parameters
final ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // set compression method to
// deflate compressio
// Set the compression level.
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
parameters.setEncryptFiles(true);
// Set the encryption method to Standard Zip Encryption
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
// Set password
parameters.setPassword(password);
zipFile.addFiles(filesToAdd, parameters);