4

I need to unzip password protected file.

I am asking for library to include to my Windows project, not utility.

Requirements:

  • password supported
  • C or C++
  • not MFC-depended
  • wish it not be DLL(as they are usualy compiled in some incompatible mode)

Already searched SO and Google, unfortunately no libraries found yet.

  • most recommended "zlib" doesn't support passwords;
  • "Zip Utils" by Lucian Wischick (here) is nice, but there's a bug - extracted file is cropped at end;
  • another library I found is MFC-depended.

I can't believe there is no solution for this simple task in 2012. Please help.

Nex
  • 361
  • 3
  • 10
  • What does the password do? Is it the key to decrypting the contents? What encryption algorithm does it use? There are many ways to password protect a zip file. So it is going to be impossible to write a library that handles them all. – Chad Dec 28 '12 at 18:13
  • @Chad Pretty sure he's looking for one of "the two" widely-used password encryption schemes for zip file encryption (the ridiculously easy-to-break PKWare "encryption", or the WinZip AES-256 Encryption model. Possibly both. – WhozCraig Dec 28 '12 at 18:22
  • @WhozCraig - That is the thing... you dont know. And if the OP knew he could find what he wanted as well. – Chad Dec 28 '12 at 18:24
  • @Chad zip-file is encrypted via linux shell script command. Some standard syntax. Obviously not Winzip. – Nex Dec 28 '12 at 19:00
  • @Chad "What does the password do? Is it the key to decrypting the contents?" Yes it is the key to decrypting the contents. Archive is created initially with password. So any user can see filenames list inside archive but not content of these files. – Nex Dec 28 '12 at 19:10
  • @Chad I can extract it manually. No problem. But I need to do it in my program at runtime, without user interaction and not depend on external utilities. So I need some C/C++ library to handle this task. Do you know some library, able to unzip password protected file, with requirements as shown in my post? – Nex Dec 28 '12 at 19:16
  • @Chad Is there any library that meet my requirements and support at least ONE(no mater which one) password encryption? I will use that library and that encryption type. – Nex Dec 28 '12 at 19:49
  • @Nex - http://stackoverflow.com/questions/120116/encryption-libraries – Chad Dec 28 '12 at 19:51
  • 1
    @Chad This link is for C# .Net. I need C or C++ library. See requirements in my post. – Nex Dec 28 '12 at 19:55
  • @Nex - Did you look to see if they worked in C++? I Think they do. That is why I downvoted the question... – Chad Dec 28 '12 at 20:06
  • 1
    @Chad I need zip library with encryption support, not just encryption library. Read my post. – Nex Dec 29 '12 at 04:05
  • @Chad You still did not mentioned even a single zip-library. So you just don't know any libraries and keep wasting my time. – Nex Dec 29 '12 at 04:13
  • @Nex there are Zip libraries that are part of WindowsBase components in VS... move along please – Chad Dec 29 '12 at 06:02
  • @Chad that is for .Net. I've told you already I want just plain C or C++ library. Dont waste my time with .Net anymore. You dont know any C or C++ library for unzipping. – Nex Dec 29 '12 at 07:10

3 Answers3

4

Ended up using "Zip Utils" by Lucian Wischick.

There was a bug - extracted file is cropped by 12 bytes at end. I found out how to fix it.

To fix this bug, delete line 3657 in file "unzip.cpp":

pfile_in_zip_read_info->rest_read_uncompressed-=uDoEncHead;
Nex
  • 361
  • 3
  • 10
  • Having a quick look through the code, it seems like that project has simply squashed all of libzip and zlib into two files (you can still see comments referring to libzip.h) libzip does support tradition encryption as well, but not AES encryption, which is what I'm trying to track down (and I couldn't see any code in this library that gave me confidence it would be supported) – Grant Peters Dec 08 '14 at 12:57
2

UPDATED: use 7-zip as a library

Test if your password protected file can be decompressed with 7-zip.
If that is the case, then you should be able to use the codebase (as a dll).

The tool has support for zip decompression (ZlibDecoder) and 2 possible different encryption techniques (ZipCrypto & ZipStrong).


As for instructions how to use it, the 7-zip file manager tool uses the 7-zip dll to do all the work. You will need to look at the source code of the command line tool 7z.

user1055604
  • 1,624
  • 11
  • 28
  • Are there any instructions of how to do it? Tried to figure out, but it is too complex. – Nex Dec 29 '12 at 10:43
0

You can try Info ZIP. It is open-source, and supports archive encryption: http://sourceforge.net/projects/infozip/

Nickolay Olshevsky
  • 13,706
  • 1
  • 34
  • 48
  • It is not actually a library. It is just an open-source utility. So it can be used, but only with a lot extra time to find out how to include in my project. Docs how to do this not exist or can't be found. – Nex Feb 13 '13 at 09:47