Sunny Shah
Sunny Shah

Reputation: 13020

Ziparchive not talking password for the password protected zip file?

I have password protected zip file. I want to unzip that file but for the right password.

Right not what happening that even if I enter a wrong password the file is unziped.

I am using the following method for that?

    [zipArchive UnzipOpenFile:strUnZip Password:@"121224"];

Password argument is unused. if i put then still unzip the files.

So how to check if user enter a right password for the password protected file.

Upvotes: 1

Views: 1126

Answers (1)

Anya Shenanigans
Anya Shenanigans

Reputation: 94604

Zip passwords are on a per-file entry basis. The password only applies to individual files within the zipfile. The use of a password on file open is a simplification of the feature which has it's issues.

As a result, even if you get the password incorrect, you can simply open the archive without issue.

The password only applies when you attempt to extract files from the archive, as a result, that is the only time the password would come into effect.

The workaround is to check for failure at extraction time - in the UnzipFileTo call.

Note: not having all the files encrypted is pretty unusual, but I've done it myself in the past; I've even put files in the archive with different password.

Upvotes: 1

Related Questions