Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Mk/add support for extracting password protected LZMA(2) 7z archives #324
I have a few problems with the archive attached, password "password", created with 7zip 16.04. Had to zip it first to be able to upload it here:
Firstly, there is no way to test if archive is encrypted or not. The IsEncrypted property of all the entries is false. To explain a business case - often we get a list of 7z archives and a list of passwords - we need to try the passwords if needed.
Secondly, with password "fdsa" the first two file entries are "successfully" extracted to stream with no exception thrown. The content of these files is, however, still somehow encrypted. The third entry throws an exception.
Thirdly, the invalid password exception would be appreciated. Currently there is no way to catch SharpCompress exceptions as they are protected.
Finally, I have managed to work around the issues mentioned above by trying to extract all the entries into the temp stream first and catching any kind of exception. If no exception is thrown, I know I have a good password (if any). This is of course not ideal as we run through the extraction twice. Also, there is a risk that no exception will be thrown as observed with the first two entries.
Any comments/suggestions/fixes are appreciated.
Thanks for your efforts to support 7z.
Sounds like there could be some reworking of encryption handling. I think creating an issue is more valid here.
I need to check the zip spec but sometimes (maybe just RAR) you only know if the decryption worked if there's an exception. No other way to know if a password is valid.