我使用过zip4j来压缩某些文件。它能够正确压缩,并在提取它的同时还要求输入密码。到目前为止,一切都很顺利。现在我面临的问题
我的要求是锁定一些文件,用户应该不能操纵压缩。(点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);
发布于 2019-05-27 20:41:54
根据Zip format specification,您正在寻找的功能称为“强加密”。链接中的"7.0强加密规范“一节介绍了此加密标准。该技术还对zip报头信息进行了加密,因此,如果没有密码,则无法修改zip文件。但是,此功能是专有的和受专利保护的。AFAIK,库/应用程序需要权限才能实现/支持此功能。Zip4j目前不支持此功能。
https://stackoverflow.com/questions/56273295
复制相似问题