How to Decrypt, Remove Password Protection from a Zip File using C# .NET Framework

Cloudmersive
2 min readJan 25, 2024

--

With a low-code API solution, we can easily unlock secure zip files by submitting our file & password through simple request parameters.

Using the below code, we can take advantage of an API for exactly that purpose with minimal hassle. We’ll be able to submit our file in a multipart/form-data request with our password string included, and the operation will return the zip file without security measures attached (so we can subsequently unzip its contents).

Our first step is to install the SDK. We can install via NuGet by running the below command in our Package Manager console:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.4.2

Next, we can call the function using the below code, and we can enter our file contents & zip password into the appropriate (labeled) parameters:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;

namespace Example
{
public class ZipArchiveZipDecryptExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");

var apiInstance = new ZipArchiveApi();
var inputFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on.
var zipPassword = zipPassword_example; // string | Required; Password for the input archive

try
{
// Decrypt and remove password protection on a zip file
Object result = apiInstance.ZipArchiveZipDecrypt(inputFile, zipPassword);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling ZipArchiveApi.ZipArchiveZipDecrypt: " + e.Message );
}
}
}
}

Now we’ll just need a free API key to authorize our requests, and we’ll be able to make up to 800 API calls per month with zero commitments.

That’s all there is to it — no more code required!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet