Java 受密码保护的zip文件,而不是zip中的文件
我要创建受密码保护的ZIP:Java 受密码保护的zip文件,而不是zip中的文件,java,zip4j,Java,Zip4j,我要创建受密码保护的ZIP: // Set the compression level parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); // Set the encryption flag to true // If this is set to false, then the rest of encryption properties are ignored parameters.setEncryptF
// Set the compression level
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
// Set the encryption flag to true
// If this is set to false, then the rest of encryption properties are ignored
parameters.setEncryptFiles(true);
// Set the encryption method to Standard Zip Encryption
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
// Set password
parameters.setPassword(password);
但这只是加密zip中的文件,但我可以打开此zip并查看其中的文件。这不是我想要的。我想让zip密码受到保护,而不是它里面的文件。不可能,抱歉
这样的文件不符合.ZIP文件格式规范。它指出,虽然实际文件已加密,但元数据(包括文件名和大小)未加密。这一直是一个争论的话题,但事实就是这样。它的一个用途是,你可以得到你漂亮的“密码不正确”而不是垃圾文件
无论哪种方式-不要依赖.zip文件加密。这很糟糕。不,真的-非常非常糟糕。它很容易受到一系列攻击
如果你想要一个正确加密的.zip文件,就这么做吧。创建一个.zip文件,然后使用适当的加密来创建一个加密文件。Java有相当多的加密功能。只需在一个zip中创建一个zip,并对内部zip进行加密:)更重要的是,这是不可能的。.ZIP文件格式规范声明,包括内容列表在内的元数据未加密。其中一个用途是验证正确的解密。还有其他方法可以保护zip密码吗?您可以使用
winzipaes
@vzamanillo,但当我尝试使用winzipaesi时,无法打开zip文件夹中的文件。它显示“windows无法完成解压缩”错误消息。@或谢谢您的帮助。您能建议一些有用的链接吗?@paramouv