vs2010的VB.NET压缩包文件密码恢复软件代码QZQ

Imports System.IO
Imports Ionic.Zip
Imports System.Threading

Public Class Form1

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
   
    Dim zipFilePath As String = "C:\Users\Administrator\Desktop\2\1.zip" ' 压缩包文件路径
    Dim passwordDictPath As String = "C:\Users\Administrator\Desktop\2\mm.txt" ' 密码字典文件路径


    Dim passwords As List(Of String) = ReadPasswordsFromFile(passwordDictPath)

    Dim correctPassword As String = TryUnlockWithPasswords(zipFilePath, passwords)

    If correctPassword <> "" Then
        MessageBox.Show("密码匹配成功,正确密码是:" & correctPassword)
    Else
        MessageBox.Show("所有密码尝试均失败,未找到正确密码。")
    End If
End Sub

Function ReadPasswordsFromFile(ByVal filePath As String) As List(Of String)
    Dim passwords As New List(Of String)
    Try
        Using reader As New StreamReader(filePath)
            Dim line As String
            While Not reader.EndOfStream
                line = reader.ReadLine()
                passwords.Add(line)
            End While
        End Using
    Catch ex As Exception
        MessageBox.Show("读取密码文件时发生错误: " & ex.Message)
    End Try
    Return passwords
End Function

Function TryUnlockWithPasswords(ByVal zipPath As String, ByVal passwords As List(Of String)) As String
    Try
        Using zip As ZipFile = ZipFile.Read(zipPath)
            For Each password As String In passwords
                zip.Password = password
                TextBox1.Text &= "正在尝试密码:" & password & vbNewLine ' 将正在尝试的密码显示在文本框中

                TextBox1.Refresh() ' 刷新文本框以立即显示新添加的内容

                Thread.Sleep(10) ' 延时 0.01 秒,可根据需要调整时长
                If ZipFile.CheckZipPassword(zipPath, password) Then
                    Return password
                End If
            Next
        End Using
    Catch ex As Exception
        MessageBox.Show("尝试解锁时发生错误: " & ex.Message)
    End Try
    Return ""
End Function

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim i, j As Integer
    Dim a() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}

    For i = 0 To 9
        For j = 0 To 9
            TextBox1.Text = TextBox1.Text & a(i) & a(j) & vbCrLf
        Next
    Next
End Sub

End Class

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

易软科技(河源)有限公司

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值