How to Encrypt and Password Protect a Zip File in Java

Zip files are ideal for storing and sharing large amounts of sensitive information. To provide an extra level of protection, you can choose to encrypt and even password protect your file to prevent any unwanted access. The following API will allow you to perform these actions by inputting an encryption request including the file contents, desired password, and encryption algorithm.

Image for post
Image for post

You can use this API by running this command to install the SDK:

pip install cloudmersive-convert-api-client

Then, you can call the function:

from __future__ import print_function
import time
import cloudmersive_convert_api_client
from import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_convert_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_convert_api_client.ZipArchiveApi(cloudmersive_convert_api_client.ApiClient(configuration))
encryption_request = cloudmersive_convert_api_client.ZipEncryptionAdvancedRequest() # ZipEncryptionAdvancedRequest | Encryption request
# Encrypt and password protect a zip file
api_response = api_instance.zip_archive_zip_encrypt_advanced(encryption_request)
except ApiException as e:
print("Exception when calling ZipArchiveApi->zip_archive_zip_encrypt_advanced: %s\n" % e)

The API Key for this function can be retrieved at no cost and with no commitment on the Cloudmersive website. This will give you access to 800 monthly calls across our entire API library.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store