sharpcompress icon indicating copy to clipboard operation
sharpcompress copied to clipboard

Unable to unRAR version 5.5 file

Open xuejf-super opened this issue 4 years ago • 6 comments

xuejf-super avatar Mar 26 '20 04:03 xuejf-super

Going to need more detail.

Don’t believe they’ve changed the format again but I could be wrong.

adamhathcock avatar Mar 26 '20 07:03 adamhathcock

The following code is used to decompress the compressed file of RAR 5.5, and an exception "file crc mismatch" is thrown

string path = @"C:\Users\Administrator\Desktop\1\1\2222.rar"; string fpath = @"C:\Users\Administrator\Desktop\1\1\2222"; using (Stream stream = File.OpenRead(path)) { var reader = ReaderFactory.Open(stream, new ReaderOptions() { Password = "cxmt1508" }); while (reader.MoveToNextEntry()) { if (!reader.Entry.IsDirectory) { Console.WriteLine(reader.Entry.Key); reader.WriteEntryToDirectory(fpath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } }

xuejf-super avatar Mar 26 '20 07:03 xuejf-super

RAR5 decryption isn't currently implemented

adamhathcock avatar Mar 26 '20 07:03 adamhathcock

okay, thank you

xuejf-super avatar Mar 26 '20 07:03 xuejf-super

SharpCompress Version="0.32.2"

Likewise, getting error on unrar / decryption,

Unhandled exception. System.InvalidOperationException: TODO rar5
   at SharpCompress.Common.Rar.Headers.FileHeader.get_FileCrc()
   at SharpCompress.Compressors.Rar.MultiVolumeReadOnlyStream.InitializeNextFilePart()
   at SharpCompress.Compressors.Rar.MultiVolumeReadOnlyStream..ctor(IEnumerable`1 parts, IExtractionListener streamListener)
   at SharpCompress.Archives.Rar.RarArchiveEntry.OpenEntryStream()
   at SharpCompress.Archives.IArchiveEntryExtensions.WriteTo(IArchiveEntry archiveEntry, Stream streamToWriteTo)
   at SharpCompress.Archives.IArchiveEntryExtensions.<>c__DisplayClass2_0.<WriteToFile>b__0(String x, FileMode fm)
   at SharpCompress.Common.ExtractionMethods.WriteEntryToFile(IEntry entry, String destinationFileName, ExtractionOptions options, Action`2 openAndWrite)
   at SharpCompress.Archives.IArchiveEntryExtensions.WriteToFile(IArchiveEntry entry, String destinationFileName, ExtractionOptions options)
   at SharpCompress.Common.ExtractionMethods.WriteEntryToDirectory(IEntry entry, String destinationDirectory, ExtractionOptions options, Action`2 write)
   at SharpCompress.Archives.IArchiveEntryExtensions.WriteToDirectory(IArchiveEntry entry, String destinationDirectory, ExtractionOptions options)
   at ConsoleApp.MediaTool.ExtractRar(String filePath) in D:\Code\CS\MediaTool\ConsoleApp\MediaTool.cs:line 104

atiq-cs avatar Dec 19 '22 00:12 atiq-cs

So we think there's a 5.5 specification change?

That exception is because the RAR 5 CRC isn't implemented properly.

adamhathcock avatar Dec 19 '22 09:12 adamhathcock