sharpcompress
sharpcompress copied to clipboard
Detect if rar file is password protected?
Hi,
Is there any way to check if a rar or another other type is password protected? Currently I check if it throws a CryptographicException but this does not work for .rar files where the filenames are not encrypted, when I then try to open the entrystream or extract the entries I get a NullReferenceException.
Thanks!
I might be doing something wrong for that case. I think the only encryption flag I check for RARs is on the ArchiveHeader.
I'd have to dig into the spec.
Could be a good PR.
I noticed this issue and found that checking IsEncrypted on the Entry was the best method. If you're not using passwords then you should not attempt to process an Entry with IsEncrypted is True.
If the archive is encrypted with encrypted filenames then catching SharpCompresses CryptographicException when no password is set indicates it's passworded.