📄 加密解密文件.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "加密/解密文件"
ClientHeight = 5880
ClientLeft = 60
ClientTop = 345
ClientWidth = 5445
LinkTopic = "Form1"
ScaleHeight = 5880
ScaleWidth = 5445
StartUpPosition = 3 '窗口缺省
Begin VB.CheckBox Check1
Caption = "显示全部文件"
Height = 255
Left = 3540
TabIndex = 8
Top = 2940
Width = 1635
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 315
Left = 3840
TabIndex = 7
Top = 1860
Width = 1155
End
Begin VB.CommandButton Command1
Caption = "加密/解密"
Height = 315
Left = 3840
TabIndex = 6
Top = 1260
Width = 1155
End
Begin VB.FileListBox File1
Height = 1170
Left = 120
Pattern = "*.txt"
TabIndex = 4
Top = 2040
Width = 3195
End
Begin VB.TextBox Text2
Height = 270
Left = 4140
TabIndex = 3
Top = 180
Width = 1155
End
Begin VB.TextBox Text1
Height = 2415
Left = 60
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 2
Top = 3360
Width = 5235
End
Begin VB.DirListBox Dir1
Height = 1350
Left = 120
TabIndex = 1
Top = 540
Width = 3195
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 120
TabIndex = 0
Top = 120
Width = 3195
End
Begin VB.Label Label1
Caption = "密码:"
Height = 195
Left = 3480
TabIndex = 5
Top = 240
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Long
Dim DataBuff() As Byte
Dim AddBuff() As Byte
Dim password() As Byte
Dim FileName As String
Private Sub Check1_Click()
If Check1.Value Then
File1.Pattern = "*.*"
Else
File1.Pattern = "*.txt"
End If
End Sub
Private Sub Command1_Click()
Dim j As Integer
Dim password_len As Integer
password_len = Len(Text2.Text)
ReDim password(password_len) As Byte
For i = 0 To password_len - 1
password(i) = Asc(Mid(Text2.Text, i + 1, 1))
Next i
If FileName = "" Then Exit Sub
Open FileName For Binary As #1
ReDim DataBuff(LOF(1))
Get #1, , DataBuff
Close #1
ReDim AddBuff(UBound(DataBuff)) As Byte
For i = 0 To UBound(DataBuff)
If j >= password_len Then
j = 0
Else
j = j + 1
End If
AddBuff(i) = DataBuff(i) Xor password(j)
Next i
Open FileName For Binary As #1
Put #1, , AddBuff
Close #1
Text1.Text = StrConv(AddBuff, vbUnicode)
Text2.Text = ""
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error GoTo a0
Dir1.Path = Drive1.Drive
Exit Sub
a0:
If Err Then MsgBox (Error(Err))
End Sub
Private Sub File1_Click()
FileName = Dir1.Path + "\" + File1.FileName
If FileName = "" Then Exit Sub
Open FileName For Binary As #1
ReDim DataBuff(LOF(1))
Get #1, , DataBuff
Close #1
Text1.Text = StrConv(DataBuff, vbUnicode)
MsgBox TypeName(StrConv(DataBuff, vbUnicode))
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -