Excel files corrupted after extraction in password protected RAR file #374

Closed
opened 2026-01-29 22:10:55 +00:00 by claunia · 5 comments
Owner

Originally created by @Mohammadhamza43 on GitHub (Sep 14, 2019).

I want to extract the password protected .rar file but when i extracted the .rar file the folder containing the excel file extracted but all the files in there are corrupted. It works fine when i extract non-password protected file.

Directory Structure:
example.rar --> example --> book1.xlsx

This is what i m doing:
using (var archive = RarArchive.Open(@"C:\Users\User\Desktop\example.rar", new SharpCompress.Readers.ReaderOptions() {
Password = "12345678"
}))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory("D:\temp1", new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true,
});
}
}

Originally created by @Mohammadhamza43 on GitHub (Sep 14, 2019). I want to extract the password protected .rar file but when i extracted the .rar file the folder containing the excel file extracted but all the files in there are corrupted. It works fine when i extract non-password protected file. Directory Structure: example.rar --> example --> book1.xlsx This is what i m doing: using (var archive = RarArchive.Open(@"C:\Users\User\Desktop\example.rar", new SharpCompress.Readers.ReaderOptions() { Password = "12345678" })) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { entry.WriteToDirectory("D:\\temp1", new ExtractionOptions() { ExtractFullPath = true, Overwrite = true, }); } }
Author
Owner

@adamhathcock commented on GitHub (Sep 14, 2019):

Probably is the wrong password. The only way to detect wrong passwords is with CRC if I recall correctly.

@adamhathcock commented on GitHub (Sep 14, 2019): Probably is the wrong password. The only way to detect wrong passwords is with CRC if I recall correctly.
Author
Owner

@Mohammadhamza43 commented on GitHub (Sep 17, 2019):

extracting a file with wrong password is possible? Working fine when i m extracting the same file using command line

@Mohammadhamza43 commented on GitHub (Sep 17, 2019): extracting a file with wrong password is possible? Working fine when i m extracting the same file using command line
Author
Owner

@adamhathcock commented on GitHub (Sep 17, 2019):

What are you saying? WinRAR itself will extract the file with the correct password?

Incorrect password will extract garbage as there’s no way to detect if the password is correct without doing a CRC of the file.

@adamhathcock commented on GitHub (Sep 17, 2019): What are you saying? WinRAR itself will extract the file with the correct password? Incorrect password will extract garbage as there’s no way to detect if the password is correct without doing a CRC of the file.
Author
Owner

@Mohammadhamza43 commented on GitHub (Sep 18, 2019):

what i m saying is that when i extract the same file manually using winrar with the same password it works fine. but with the above code its giving me garbage

@Mohammadhamza43 commented on GitHub (Sep 18, 2019): what i m saying is that when i extract the same file manually using winrar with the same password it works fine. but with the above code its giving me garbage
Author
Owner

@adamhathcock commented on GitHub (Sep 18, 2019):

I'm not sure what to tell you unless you can speak more of the encryption options and how they're different from the tests in the repo

@adamhathcock commented on GitHub (Sep 18, 2019): I'm not sure what to tell you unless you can speak more of the encryption options and how they're different from the tests in the repo
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#374