简体   繁体   English

使用Java创建受密码保护的ZIP

[英]Creating Password Protected ZIP using Java

I trying to create ZIP file with password protection. 我试图创建具有密码保护的ZIP文件。 But available libraries protecting the Files inside the ZIP. 但是可用的库保护ZIP中的文件。 I have tried Zip4j and AesZipFileEncrypter but all these protecting the files only not the ZIP file. 我已经尝试过Zip4jAesZipFileEncrypter但是所有这些仅保护ZIP文件而不保护文件。 The code mentioned in the Question is also Zipping the files only. 问题中提到的代码也仅压缩文件。 Stack Overflow Question . 堆栈溢出问题

"http://code.google.com/p/winzipaes/" “ http://code.google.com/p/winzipaes/”

This API helps to add a password to a already created zip file. 此API有助于将密码添加到已创建的zip文件中。 It means that if you want to create a password protected zip file, first you have to create a zip file and then you can add a password that zip file. 这意味着,如果要创建一个受密码保护的zip文件,首先必须创建一个zip文件,然后可以添加该zip文件的密码。 It is a pure java API works with any operating system. 它是适用于任何操作系统的纯Java API。 You have to download the following jar file from the above URL. 您必须从上述URL下载以下jar文件。

It is because Zip-encrypted file is a Zip, with inside files encrypted. 这是因为Zip加密的文件是Zip,内部文件已加密。 details of encryption (algorithm, ...) is kept inside zip format. 加密的详细信息(算法等)以zip格式保存。

The ZIP APIs manage that. ZIP API对此进行了管理。

What you want is an encrypted file (independent of content which is Zip). 您需要的是一个加密文件(与Zip内容无关)。

1 To do that, you can use many methods and algorithms like this: 1为此,您可以使用许多类似的方法和算法:

How to encrypt and decrypt files with bouncy castle (DES) in netbeans java? 如何在NetBeans Java中使用弹性城堡(DES)加密和解密文件?

2 but result will not be recognized as zip file, then usual tools wont work. 2,但结果将不会被识别为zip文件,那么常规工具将无法工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM