Failed to open file on RAR 5.0 with option "Encrypt file names" #489

Open
opened 2026-01-29 22:12:51 +00:00 by claunia · 2 comments
Owner

Originally created by @ghost on GitHub (Jan 21, 2022).

If you create rar file with password, and this option "Encrypt file names", sharpcompress cannot open the file.

It works on RAR 4.X, but it does not work on RAR 5.0

Test C# Code:
.net 6.0 With Visual Studio 2022

using SharpCompress.Archives;
using SharpCompress.Readers;

var filePassword = "123";

var options = new ReaderOptions()
{
    Password = filePassword,
};

var filePath = @"D:\CSHARP_ZIP_TEST_CODE\123.rar";
var stream = File.OpenRead(filePath);

var archive = ArchiveFactory.Open(stream, options);

foreach (var part in archive.Entries)
{
    Console.WriteLine(part.Key);
}

Test Result:

System.FormatException:“malformed vint”
Originally created by @ghost on GitHub (Jan 21, 2022). If you create rar file with password, and this option **"Encrypt file names"**, sharpcompress cannot open the file. It works on RAR 4.X, but it does not work on RAR 5.0 Test C# Code: .net 6.0 With Visual Studio 2022 ``` using SharpCompress.Archives; using SharpCompress.Readers; var filePassword = "123"; var options = new ReaderOptions() { Password = filePassword, }; var filePath = @"D:\CSHARP_ZIP_TEST_CODE\123.rar"; var stream = File.OpenRead(filePath); var archive = ArchiveFactory.Open(stream, options); foreach (var part in archive.Entries) { Console.WriteLine(part.Key); } ``` Test Result: ``` System.FormatException:“malformed vint” ```
Author
Owner

@adamhathcock commented on GitHub (Jan 21, 2022):

RAR 5.0 decryption is a known TODO: https://github.com/adamhathcock/sharpcompress#todos-always-lots

@adamhathcock commented on GitHub (Jan 21, 2022): RAR 5.0 decryption is a known TODO: https://github.com/adamhathcock/sharpcompress#todos-always-lots
Author
Owner

@ghost commented on GitHub (Jan 22, 2022):

Thank you, I can use this library to read my RAR 5.0 files normally, but if it has option "Encrypt file names", it will not work now.

@ghost commented on GitHub (Jan 22, 2022): Thank you, I can use this library to read my RAR 5.0 files normally, but if it has option **"Encrypt file names"**, it will not work now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#489