QuaZip - Password protected files

2.9k views Asked by At

I'm looking at extracting password protected files from a .zip and found that QuaZip has the function below but no code examples or additional documentation on how to work with encrypted files.

Is it definitely possible to extract the encrypted files in QuaZip? and if it is where are some examples please :)

bool open (OpenMode mode, const char *password)

Opens a file for reading.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Argument password specifies a password to decrypt the file. If it is NULL then this function behaves just like open(OpenMode).

References open().

Referenced by open().

QuaZip Docs

1

There are 1 answers

0
Ilya On BEST ANSWER

Try this:

QuaZip zip("file.zip"); // put real zip file name here
zip.open(QuaZip::mdUnzip);
QuaZipFile file(&zip);
for(bool f=zip.goToFirstFile(); f; f=zip.goToNextFile()) {
    file.open(QIODevice::ReadOnly, "password"); // put real password here
    file.readData(data, maxSize);
    // process data from archive
    file.close();
}    
zip.close();