adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.25k stars 479 forks source link

Unable to unRAR version 5.5 file #503

Open xuejf-super opened 4 years ago

adamhathcock commented 4 years ago

Going to need more detail.

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

xuejf-super commented 4 years ago

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 }); } } }

adamhathcock commented 4 years ago

RAR5 decryption isn't currently implemented

xuejf-super commented 4 years ago

okay, thank you

atiq-cs commented 1 year ago
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
adamhathcock commented 1 year ago

So we think there's a 5.5 specification change?

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