views:

149

answers:

2

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 considering I'll be unzipping 100 files or so, this is less than ideal.

+1  A: 

This looks promising.

Luke
Evan
A: 

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?

Cheeso