Hi,
128 and 256 bit AES is supported in the latest version, which is not yet been officially released, but will be soon.
Please download the dll from
http://blissfloral.com.au/ref/ICSharpCode.SharpZipLib.zip
I'm delighted to see more interest in this feature. It was the reason I joined the forum originally and my first post was asking if anyone had made any progress. I ended up adding it myself :-)
It works for creation and extraction, except that for extraction, you must use the ZipFile class and not ZipInputStream as I have not yet updated that. For creation, both ZipFile and ZipOutputStream are fully functional.
Here is sample code to create a 256 bit AES zip file.
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
public void CreateSample(string outPathname, string password, List<String> contents) {
FileStream fsOut = File.Create(outPathname);
ZipOutputStream zipStream = new ZipOutputStream(fsOut);
zipStream.SetLevel(3); //0-9, 9 being the highest level of compression
zipStream.Password = password;
foreach (string filename in contents) {
string entryName = StrippedFilename(filename);
ZipEntry newEntry = new ZipEntry(entryName);
newEntry.DateTime = DateTime.Now;
// Specifying the AESKeySize triggers AES encryption. Allowable values are 0 (off), 128 or 256.
newEntry.AESKeySize = 256;
// Use Off to permit the zip to be unpacked by XP's built-in extractor and other older
// code. Use On or Dynamic if the file will be bigger than 4GB.
zipStream.UseZip64 = UseZip64.Off;
zipStream.PutNextEntry(newEntry);
// zip file in buffered chunks
// the "using" will close the stream even if an exception occurs
byte[ ] buffer = new byte[4096];
using (FileStream streamReader = File.OpenRead(filename)) {
StreamUtils.Copy(streamReader, zipStream, buffer);
}
zipStream.CloseEntry();
}
zipStream.IsStreamOwner = true; // Makes the Close also Close the underlying stream
zipStream.Close();
}
// Remove drive from name eg "C:\temp\file.txt" -> "temp\file.txt"
// Many utilities object to presence of disk in path.
private string StrippedFilename(string filename) {
string pathroot = Path.GetPathRoot(filename);
return filename.Substring(pathroot.Length);
}
public static void TestBuild() {
List<String> contents = new List <String>();
// some test files to encrypt
contents.Add(@"c:\temp\test1.txt");
contents.Add(@"c:\temp\test2.txt");
CreateSample(@"c:\temp\AES-test.zip", "whatever", contents);
}
The dll matches the current source code checked into the repository. There are more code changes for other features/bugs to be done before I do an official new release.
Hope this helps,
David
Edit: a gremlin removed the password line