adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.27k stars 481 forks source link

Not possible to supply a password when using the high level interfaces #37

Open ptallett opened 9 years ago

ptallett commented 9 years ago

When processing a password protected ZIP file using the high level IArchiveReader/Writer interfaces, it is not possible to supply the password as this functionality is only exposed by lower level interfaces.

Cheers, Paul

sepehr1014 commented 9 years ago

Any plans on adding this functionality?

ptallett commented 9 years ago

Its fairly easy to hack this. I just put a static string in the lower level class and a set method in the high level API. Not something I’m proud of though, so I didn’t check it in! :)

Cheers,

Paul

From: Sepehr Mohammad [mailto:notifications@github.com] Sent: Sunday, May 31, 2015 10:49 To: adamhathcock/sharpcompress Cc: ptallett Subject: Re: [sharpcompress] Not possible to supply a password when using the high level interfaces (#37)

Any plans on adding this functionality?

— Reply to this email directly or view it on GitHub https://github.com/adamhathcock/sharpcompress/issues/37#issuecomment-107150857 . https://github.com/notifications/beacon/AJ1R_ZJ-1emnOasyNrm8k2yfHfDAOJbeks5oOtCRgaJpZM4DMah1.gif

sepehr1014 commented 9 years ago

Thanks @ptallett but in our situation, we don't know if the files are password protected beforehand. There needs to be an event which is raised on password protected archives to get the password and continue extracting.

ptallett commented 9 years ago

Yes, that would be ideal, but you can workaround it by trying to open the ZIP file without a password, catching the exception, requesting a password, then retrying to open the ZIP file. Works a treat. You need to do something similar if the password is incorrect in any case.

The drawback with this approach is each file in a ZIP container can have a different password, but I just ignored that scenario as its rare.

Cheers,

Paul

From: Sepehr Mohammad [mailto:notifications@github.com] Sent: Sunday, May 31, 2015 12:12 To: adamhathcock/sharpcompress Cc: ptallett Subject: Re: [sharpcompress] Not possible to supply a password when using the high level interfaces (#37)

Thanks @ptallett https://github.com/ptallett but in our situation, we don't know if the files are password protected beforehand. There needs to be an event which is raised on password protected archives to get the password and continue extracting.

— Reply to this email directly or view it on GitHub https://github.com/adamhathcock/sharpcompress/issues/37#issuecomment-107156870 . https://github.com/notifications/beacon/AJ1R_cZI5fKKhyK6qAn62WW8EqO1AIr7ks5oOuPkgaJpZM4DMah1.gif