Programatically unzip an AES encrypted zip file on Windows
I need to be able to unzip some AES (WinZip) encrypted zip files from within some C/C++ code on Windows. Has anybody got a way to do this? I'm hoping for either some appropriate code or a DLL I can use (with an example usage). So far my searches have proved fruitless.
The commonly prescribed InfoZip libraries do not support AES encryption.
The best solution I have at the moment is calling the 7z.exe command line program from my program, but consid开发者_JS百科ering I'll be unzipping 100 files or so, this is less than ideal.
Here is the minizip zlib contribution with AES support for both encryption and decryption. https://github.com/nmoinvaz/minizip
DotNetZip can do it. If you're not averse to using Managed C++.
From the DotNetZip documentation, this is the code to create an AES Encrypted zip file. (The code to extract is similar).
#include "stdafx.h"
using namespace System;
using namespace Ionic::Zip;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
ZipFile ^ zip;
try
{
zip = gcnew ZipFile();
zip->Password = "Harbinger";
zip->Encryption = EncryptionAlgorithm::WinZipAes128;
zip->AddEntry("Readme.txt", "This is the content for the Readme.txt entry.");
zip->Save("test.zip");
}
finally
{
zip->~ZipFile();
}
Console::WriteLine(L"Press <ENTER> to quit.");
Console::ReadLine();
return 0;
}
Also - I wrote DotNetZip so I have a certain amount of favoritism toward it! But I don't see what's wrong with exec'ing 7z.exe 100 times? Are you concerned about performance?
http://www.artpol-software.com/ZipArchive/ is the best choice.
精彩评论