mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Extract rar with invalid password does not raise exception #20
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 @JJWR on GitHub (Dec 15, 2014).
Hello, when I extract a rar file with password everything works as expected if the password is ok. However, when the password is wrong the extraction runs without raising any exception and the files are extracted. Of course the files are corrupted. This is the code I am using:
Since we can not ensure that the extraction went well, this issue is making the library useless for rar protected files.
@Strachu commented on GitHub (Dec 16, 2014):
I am not sure whether there is a better way to do it nor if it can be done without making some modification to the library, but maybe extracting some small file to memory, calculating CRC for extracted content and comparing it with CRC from header will be enough?
If CRCs are equal == password is correct.
If CRCs are different == incorrect password or damaged archive.
@adamhathcock commented on GitHub (Dec 16, 2014):
CRC is the only way to check. It's unfortunate but I don't think there's anyway to throw an exception or something unless there's an encrypted header to check.
@JJWR commented on GitHub (Dec 26, 2014):
CRC should anyway always be checked even if the file is not password protected to ensure that the file is all right. Is is not checked now?
@adamhathcock commented on GitHub (Dec 26, 2014):
I really haven't done much with CRC checking. I don't believe any of it is done currently.
@ArunaVignesh commented on GitHub (May 10, 2021):
@adamhathcock
When extracting rar file protected with password, files extracted done successfully when password is correct. how do i check the password correct or not? Tried above @Strachu CRC checking method. its not worked correctly in my file. @Strachu can you please explain it elaborately. If anyone knows some other method, please help