mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Detect if rar file is password protected? #151
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @evpxregu on GitHub (Dec 20, 2016).
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!
@adamhathcock commented on GitHub (Dec 21, 2016):
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.
@Nanook commented on GitHub (May 4, 2022):
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.