I am using this library in C# to extract RAR files.
Is it able to extract a file even if it is password protected? It doesn't even ask for password. How is that possible?
I am creating RAR files using WinRar and putting password on them.
I am using this library in C# to extract RAR files.
Is it able to extract a file even if it is password protected? It doesn't even ask for password. How is that possible?
I am creating RAR files using WinRar and putting password on them.
我是 nunrar 和https://sharpcompress.codeplex.com/的作者
我正在解密受密码保护的 rar 存档我的下一个项目,因为我认为我已经完成了(zip 文件模糊了我的记忆)。
正如另一条评论所说,我一直在寻求帮助,但希望我能尽快完成这项工作。
(2018 年底。)使用密码解压 RAR(4 或 5 格式)存档的解决方案:安装 Nuget Packages 7z.Libs ( https://www.nuget.org/packages/7z.Libs/ ) 和 Squid-Box。 SevenZipSharp ( https://www.nuget.org/packages/Squid-Box.SevenZipSharp/ )。使用此代码:(编辑:纠错)
public void Unpack()
{
var rawBytes = File.ReadAllBytes(".\\Some.rar");
using (var stream = new MemoryStream(rawBytes, true))
{
// Toggle between the x86 and x64 bit dll
var path = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
SevenZip.SevenZipBase.SetLibraryPath(path);
using (var outMemStream = File.Create(".\\SomeSingleFile.txt"))
{
var extractor = new SevenZipExtractor(stream, "passwordXXX");
var entry = extractor.ArchiveFileData.Single(info => false == info.IsDirectory);
extractor.ExtractFile(entry.Index, outMemStream);
}
}
}