Sign in to follow this  

Minizip encrypted file passwords

This topic is 2395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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("test.zip");
unzGoToFirstFile(zip);
unz_file_info* pfile_info = new unz_file_info;
char name[1024];
char extra[1024];
char comment[1024];
unzGetCurrentFileInfo(zip,pfile_info,name,1024,extra,1024,comment,1024);
Print(std::string(name));
bool ok = false;
if (1 & pfile_info->flag)
{
if (unzOpenCurrentFilePassword(zip,"monkey")==UNZ_OK) ok = true;
}
else
{
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(data->PeekString(0));
}
else
{
Notify("Error reading file.");
}
unzCloseCurrentFile(zip);
}
else
{
Notify("Error opening file.");
}[/code]

Share this post


Link to post
Share on other sites
Hidden
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.

[quote]
/* 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
NOCRYPT and NOUNCRYPT.

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

The new AES encryption added on Zip format by Winzip (see the page
[url="http://www.winzip.com/aes_info.htm"]http://www.winzip.com/aes_info.htm[/url] ) and PKWare PKZip 5.x Strong
Encryption is not supported.
*/
[/quote]

Share this post


Link to post

This topic is 2395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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