How to Decrypt a ZIP File in JavaScript

Cloudmersive
1 min readJun 1, 2021

--

While encrypted ZIP files are ideal for compressing large amounts of data into a safe and shareable format, they aren’t exactly known for their user-friendly design. To simplify access to the ZIP files, the following API can be used in JavaScript to automatically decrypt and remove password protection. The required parameters for running this function include the input file as well as the password for the input archive.

We will start things off by installing the jQuery library with this command:

bower install jquery

Once the installation is complete, we can add the aforementioned parameters and our API key to the following code:

var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");
var settings = {
"url": "https://api.cloudmersive.com/convert/edit/pdf/decrypt",
"method": "POST",
"timeout": 0,
"headers": {
"password": "<string>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

In no time at all, your zip archive will be returned in a more accessible and viewable package. If you need to obtain an API key, you can do so by registering for a free account on the Cloudmersive website; this provides 800 monthly calls across any of our APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet