Protect ZipArchive
RadZipLibrary lets you protect a ZIP archive with a password. This help article will teach you how to use RadZipLibrary to password-protect files and how to open files that are protected with a password. To protect a ZIP archive and all ZipArchiveEntry items in it, you should specify encryption settings when creating the ZipArchive object.
RadZipLibrary supports the following encryption algorithms:
Traditional PKWARE encryption algorithm - the settings for this encryption type are represented by the PasswordEncryptionSettings class.
Strong AES encryption algorithm - introduced in 2024 Q1.
AES encryption (Advanced Encryption Standard) is commonly used to secure sensitive information, such as credit card numbers, passwords, and personal data. It uses a symmetric-key algorithm, meaning the same key is used for both encrypting and decrypting the data. AES encryption uses a fixed-length key of 128, 192, or 256 bits to encrypt and decrypt data.
Create a Password-Protected ZipArchive
In order to create a password-protected ZIP archive, you need to pass a PasswordEncryptionSettings object to the ZipArchive's constructor along with the CompressionSettings and Encoding parameter.
PasswordEncryptionSettings has a Password property of type string, which represents the used password.
Example 1: Create a password-protected ZIP archive
You must always dispose of the ZIP archive object when all operations that use it are completed. Telerik Support recommends that you declare and instantiate the ZIP archive object in a using statement. If it is not possible for some reason, then do not forget to call the Dispose() method when you complete all operations.
Read a Password-Protected ZipArchive
In order to open a password-protected ZipArchive, you need to pass a DefaultEncryptionSettings object with the password that was used to create the archive in the first place.
Example 2: Open and read a password-protected ZIP archive
You must always dispose of the ZIP archive object when all operations that use it are completed. We recommend that you declare and instantiate the ZIP archive object in a using statement. If it is not possible for some reason, then do not forget to call the Dispose() method when you complete all operations.