QuaZip - Password protected files

2019-09-02 05:13发布

问题:

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:

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();


标签: c++ unzip quazip