Data security is very critical when you have a huge inflow of sensitive data and wondering how to keep it safe from hackers and other security threats. There might be multiple files in a compressed archive called a ZIP file. To password protect ZIP file, you need software that can automate the whole process and save time and effort. Fortunately, there is a Java ZIP API that offers classes and methods to create a password protected ZIP robustly. In addition, you can remove password from ZIP files using Aspose.ZIP for Java. So, let’s see how to automate both functionalities.
We will cover the following points in this guide:
- Java ZIP API Installation
- Create a Password Protected ZIP File - Code Sample
- Password Protect ZIP File Online
- Remove Password from ZIP Files - Code Sample
- ZIP Password Remover - Online Tool
Java ZIP API Installation
The installation process is simplest as there is no third-party dependency involved. Aspose.ZIP for Java is a perfect choice if you are involved in a rapid application development model. Even though you face any difficulty, you can visit this installation guide. However, you may download this JAR file or use the following Maven configurations to install this Java ZIP API on your local system:
<repositories>
<repository>
<id>snapshots</id>
<name>repo</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-zip</artifactId>
<version>23.12</version>
</dependency>
</dependencies>
Create a Password Protected ZIP File - Code Sample
This section demonstrates how to password protect ZIP file using this Java ZIP API:
The following are the steps:
- Initializes a new instance of the TraditionalEncryptionSettings class with a password.
- Create an object of the ArchiveEntrySettings class.
- Instantiate an object of the Archive class with the object of the ArchiveEntrySettings class.
- Invoke the createEntry method to create a single entry within the archive.
- The save method will save the password protected ZIP file on the disk.
The following code snippet shows how to create a password protected ZIP file in Java programmatically:
This is how you can add password to a ZIP file. You can see the output in the image below:
Password Protect ZIP File Online
Besides a Java ZIP API, you can leverage an online tool to password protect ZIP file online using a web-based application. In fact, it is free and you can create a password protected ZIP with one click.
Remove Password from ZIP Files - Code Sample
Likewise, this Java ZIP API provides features to remove password from ZIP files programmatically. So, it involves a few lines of source code and you can automate the whole process.
You can follow the steps mentioned below:
- Create an instance of the ArchiveLoadOptions class.
- Create an object of the Archive class.
- Invoke the extractToDirectory method to extract all the files in the archive to the directory provided.
Copy & paste the following code snippet into your main server file to build a ZIP password remover module for your business application:
ZIP Password Remover - Online Tool
You can try this online ZIP password remover powered by Aspose.ZIP. Moreover, it offers a user-friendly user interface where you can upload files in multiple ways.
Try Now - Get a Free License
You can get a free temporary license to try the Java ZIP API without evaluation limitations.
Conclusion
This blog post covered how to create a password protected ZIP file in Java. In addition, we also implemented the feature to remove password from ZIP files programmatically. Now, you can easily develop your own ZIP password remover to automate this process. Aspose.ZIP for Java also offers online applications to remove password from ZIP files and add password to a ZIP file. Further, this is the documentation, and the API references to learn more about other functionalities offered. Above all, you can check out this Getting Started guide to start development.
Please stay in touch with aspose.com for the upcoming blog posts.
Help is Available
You can share your questions or queries on our forum.
Frequently Asked Questions – FAQs
How to create a password protected ZIP file in Java?
Aspose.ZIP for Java provides features to create password protected ZIP files in Java programmatically. However, please visit this link to get the code snippet.
How do I unzip a password protected ZIP file?
There is an online tool offered by Aspose.ZIP for Java to remove password from ZIP files. Further, you can develop a ZIP password remover by opting for this Java ZIP API. So, this link demonstrates the whole process in detail.