Jump to content
  • Advertisement
Sign in to follow this  
JoshKlint_34394

Minizip encrypted file passwords

This topic is 2613 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:
if (unzOpenCurrentFilePassword(zip,"monkey")==UNZ_OK) ok = true;
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
Advertisement
This is my complete 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.");
}

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.


/* 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.

This code support the "Traditional PKWARE Encryption".

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

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!