SevenZSharp 使用密码解码

发布于 2024-12-14 06:16:34 字数 284 浏览 4 评论 0原文

我使用 此处 的 SevenZSharp

来解码我使用的文件:

CompressionEngine.Current.Decoder.DecodeIntoDirectory(@"D:\target\host_update.7z", @"D:\target");

但我没有信息如何使用密码解码.7z 文件!?请帮我。谢谢

I work with SevenZSharp from here

for Decode file I use:

CompressionEngine.Current.Decoder.DecodeIntoDirectory(@"D:\target\host_update.7z", @"D:\target");

But I don't have information how to decode .7z file with password!? Please, help me. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千仐 2024-12-21 06:16:34

要使用支持密码和多种格式的“SevenZipSharp”...

将 SevenZipSharp.dll 导入 .Net 项目引用...

将“7zx64.dll”和“7z.dll”放入目录...

然后使用此代码用于检查通过并提取是否正确。

代码

Imports SevenZip
Public Class FrmMain
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Btn1.Click

    ''Call to set DLL depending on processor type''
    If Environment.Is64BitProcess Then
        SevenZip.SevenZipCompressor.SetLibraryPath("7zx64.dll")
    Else
        SevenZip.SevenZipCompressor.SetLibraryPath("7z.dll")
    End If

    ''Set Destination of extraction''
    Dim DestDir = Application.StartupPath

    Try
        ''Check file with password''
        Dim Ext As New SevenZipExtractor(Tb1.Text, Tb2.Text)

        If Ext.Check() Then
            ''Extract files to destination''
            Ext.BeginExtractArchive(DestDir)
        End If

    Catch ex As Exception
        MessageBox.Show(ex.ToString())
    End Try

End Sub
End Class

To use "SevenZipSharp" which DOES support passwords and a wide range of formats...

Import SevenZipSharp.dll into .Net project references...

Place "7zx64.dll" and "7z.dll" into the directory...

Then use this code to check the pass and extract if correct..

code

Imports SevenZip
Public Class FrmMain
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Btn1.Click

    ''Call to set DLL depending on processor type''
    If Environment.Is64BitProcess Then
        SevenZip.SevenZipCompressor.SetLibraryPath("7zx64.dll")
    Else
        SevenZip.SevenZipCompressor.SetLibraryPath("7z.dll")
    End If

    ''Set Destination of extraction''
    Dim DestDir = Application.StartupPath

    Try
        ''Check file with password''
        Dim Ext As New SevenZipExtractor(Tb1.Text, Tb2.Text)

        If Ext.Check() Then
            ''Extract files to destination''
            Ext.BeginExtractArchive(DestDir)
        End If

    Catch ex As Exception
        MessageBox.Show(ex.ToString())
    End Try

End Sub
End Class
水中月 2024-12-21 06:16:34

从SevenZSharp的源代码来看,它不支持密码保护的文件。

这里还有一些可能对您在 Codeplex 中有所帮助的内容。它似乎有一个名为 ICryptoGetTextPassword 的界面,如果 7z 受密码保护,您可能可以使用该界面。

编辑

进一步查看SevenZipSharp,它似乎应该支持根据其项目页面进行密码保护的存档( http://sevenzipsharp.codeplex.com/ ):

  • 支持加密和密码。

您需要从 Codeplex 下载最新的代码并自行构建,在其中您可以将有一个名为 SevenZipExtractor 的类,其中具有以下构造函数:

/// <summary>
/// Initializes a new instance of SevenZipExtractor class.
/// </summary>
/// <param name="archiveFullName">The archive full file name.</param>
/// <param name="password">Password for an encrypted archive.</param>
public SevenZipExtractor(string archiveFullName, string password)
    : base(password)
{
    Init(archiveFullName);
}

注意这与 Seven7Sharp 不同,这是 SevenZipSharp,但它适用于7z

By the look of the source code of SevenZSharp, it does not support password protected files.

Here's something else that might help you from codeplex. It seem to have an interface called ICryptoGetTextPassword that you might be able to use if the 7z is password protected.

Edit

With a bit further look at SevenZipSharp it seems that it should support password protected archives accroding to their project page ( http://sevenzipsharp.codeplex.com/ ):

  • Encryption and passwords are supported.

You need to download the latest code from Codeplex and build it yourself, in it you will have a class called SevenZipExtractor where you have the following constructor:

/// <summary>
/// Initializes a new instance of SevenZipExtractor class.
/// </summary>
/// <param name="archiveFullName">The archive full file name.</param>
/// <param name="password">Password for an encrypted archive.</param>
public SevenZipExtractor(string archiveFullName, string password)
    : base(password)
{
    Init(archiveFullName);
}

Note this is not the same as Seven7Sharp, this is SevenZipSharp, but it works with 7z.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文