Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Determine if Zip is Encrypted or Password ProtectedDownload: Chilkat .NET Assemblies C# example program to determine if a .zip is password-protected or WinZip AES encrypted. // This example discusses how to determine if a Zip is // password-protected or WinZip AES encrypted. Chilkat.Zip zip = new Chilkat.Zip(); zip.UnlockComponent("Anything for 30-day trial"); string zipFilename = "myZip.zip"; // Password-protected Zips cannot be opened without // first providing the password. // Therefore, there is a method available to test a .zip // for this condition: bool isPwdProtected = zip.IsPasswordProtected(zipFilename); if (isPwdProtected) { MessageBox.Show("This zip is password-protected and requires a password to open."); return; } // WinZip AES encrypted zips can technically be opened // without first providing a password. That is because // the encryption occurs on a per-entry basis within the // zip. It is possible that some files within the zip // may be encrypted, and others not. It is also possible // that some files within the zip may be encrypted differently // or with different passwords. It is generally not possible // to mix older Zip 2.0 encryption (password-protected) with WinZip // AES encryption. bool success = zip.OpenZip(zipFilename); if (!success) { MessageBox.Show(zip.LastErrorText); return; } // If an entry's compression method = 99, it is AES encrypted. // Your application may decide to check only the 1st entry within // the zip, or all of them: // To check the 1st entry: Chilkat.ZipEntry entry = zip.GetEntryByIndex(0); if (entry.CompressionMethod == 99) { MessageBox.Show("This zip is WinZip AES strong encrypted!"); return; } // To check all the entries within the zip: int i; int n = zip.NumEntries; for (i=0; i<n; i++) { entry = zip.GetEntryByIndex(i); if (entry.CompressionMethod == 99) { MessageBox.Show("This zip is WinZip AES strong encrypted!"); return; } } MessageBox.Show("We got here, so the Zip is not encrypted!"); Important: The download for this
example does not contain the ChilkatDotNet.dll which |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.