Sign in to follow this  

Minizip encrypted file passwords

Recommended Posts

I created a zip file with winrar, using the password "monkey" for a single file.

I open this zip file using minizip, but it produces an error when trying to read the file:
[code]if (unzOpenCurrentFilePassword(zip,"monkey")==UNZ_OK) ok = true;[/code]
Do you really just give it the raw password, or is there something else I have to do to make this work?

Share this post

Link to post
Share on other sites
This is my complete code:
[code] unzFile zip = unzOpen("");
unz_file_info* pfile_info = new unz_file_info;
char name[1024];
char extra[1024];
char comment[1024];
bool ok = false;
if (1 & pfile_info->flag)
if (unzOpenCurrentFilePassword(zip,"monkey")==UNZ_OK) ok = true;
if (unzOpenCurrentFile(zip)==UNZ_OK) ok = true;
if (ok)
Bank* data=CreateBank(pfile_info->uncompressed_size);
if (unzReadCurrentFile(zip,data->buf,data->size)==data->size)
Notify("Error reading file.");
Notify("Error opening file.");

Share this post

Link to post
Share on other sites
I look through the crypt.h file which contains the decryption functions envoked by unzOpenCurrentFilePassword() and it appears to only support traditional zip password protection not the newer AES encryption version.

/* crypt.h -- base code for crypt/uncrypt ZIPfile

Version 1.01e, February 12th, 2005

Copyright © 1998-2005 Gilles Vollant

This code is a modified version of crypting code in Infozip distribution

The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)

This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).

If you don't need crypting in your application, just define symbols

[b] This code support the "Traditional PKWARE Encryption".[/b]

The new AES encryption added on Zip format by Winzip (see the page
[url=""][/url] ) and PKWare PKZip 5.x Strong
Encryption is not supported.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this