
ZIP files are the most common format for compressing data. C# developers can quickly create encrypted or password‑protected ZIP archives in .NET. This article shows how to create encrypted ZIP files with C#.
The following topics are covered:
- [C# API to Create Encrypted ZIP Files][2]
- [Create Password-Protected ZIP Files][3]
- [Create Encrypted ZIP Files with AES Encryption][4]
- [Encrypt Folders in ZIP Files][5]
- [Encrypt Specific Files in ZIP Archives][6]
- [Create Encrypted ZIP Files with Mixed Encryption][7]
C# API to Create Encrypted ZIP Files
To create encrypted [ZIP][8] archives, use the [Aspose.ZIP for .NET API][9]. It compresses files and folders, adds them to ZIP archives, and can decompress formats like ZIP, TAR, GZIP, BZ2, 7Zip, RAR, etc. The API supports password protection and AES encryption (AES‑128, AES‑192, AES‑256).
You can either [download][10] the DLL or install it via [NuGet][11].
Install-Package Aspose.ZIP
Create Password-Protected ZIP Files
Follow these steps to create a password‑protected ZIP archive:
- Create an [Archive][12] instance with an [ArchiveEntrySettings][13] object.
- Set the password using the [TraditionalEncryptionSettings][14] object.
- Call [CreatEntry()][15] with the input file path to add a file.
- Repeat step 3 for additional files.
- Call _[Save()][16] with the output path to write the archive.
The code sample below demonstrates how to create a password‑protected ZIP file using C#.

Create Password-Protected ZIP Archives
The Archive class represents a ZIP file and provides methods to create, extract, or update archives. CreatEntry() adds a single file; overloads allow adding from a stream or FileInfo. Save() writes the archive to disk.
ArchiveEntrySettings defines compression options. TraditionalEncryptionSettings configures the legacy ZipCrypto algorithm. Its Password property sets the password for encryption or decryption.
Create Encrypted ZIP Files with AES Encryption
Use these steps to encrypt a ZIP archive with AES:
- Create an [Archive][12] instance with an [ArchiveEntrySettings][13] object.
- Set the password using [AesEncryptionSettings][19], passing the password string and an [EncryptionMethod][20].
- Call [CreatEntry()][15] with the input file path.
- Repeat step 3 for additional files.
- Call _[Save()][16] with the output path.
The sample below shows how to create an AES‑encrypted ZIP file using C#.
AesEncryptionSettings configures the AES algorithm, a symmetric block cipher. Available encryption methods are:
- Traditional — legacy PK