破解密码的循环问题
从网上下载了一个破解8位以下纯数字秘密word文档的小程序,感觉不错,但它用了3层循环,试着破解一个密码为555的文档需要了半分钟,如果是四位数密码则需要5、6分钟,怎么样改进一下,使它快些啊???
代码如下:
Private Sub cmdopendoc_Click()
Dim wd As New Word.Application
Dim strpath As String
Dim pass As String
Dim J, K, Pass_long As Integer
Dim Max_num, Min_num, I As Long
strpath = File1.Path & "\" & File1.FileName
On Error Resume Next
'程序开始
Pass_long = Val(Text2.Text)
Max_num = 10 ^ Val(Text2.Text)
Min_num = 10 ^ (Val(Text2.Text) - 1)
Flag = 0
For K = 0 To Pass_long - 1
Max_num = 10 ^ (Pass_long - K)
Min_num = 10 ^ (Pass_long - (K + 1))
For J = 0 To Pass_long - 1
cmdopendoc.MousePointer = 11
For I = IIf(Pass_long - K = 1, 0, Min_num) + J To Max_num Step Pass_long
Text1.Text = pass
Text1.Refresh
pass = String(K, "0") & I
Flag = wd.Documents.Open(FileName:=strpath, passworddocument:=pass)
'如果解密成功,打开文档,显示密码,退出过程
If Flag <> 0 Then
Label2.Caption = "文档密码"
Label2.Refresh
Text1.Text = pass
wd.Visible = True
cmdopendoc.MousePointer = 0
Exit Sub
End If
Next I
Next J
Next K
MsgBox "密码位数不对,请重新输入"
End Sub