📄 form1.frm
字号:
VERSION 5.00
Object = "{AFD14C83-A869-11D3-BD96-0080C8EB2FFE}#1.0#0"; "ApexDes.ocx"
Begin VB.Form Form1
Caption = "DES加密/解密控件功能测试软件"
ClientHeight = 9060
ClientLeft = 60
ClientTop = 405
ClientWidth = 8550
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 9060
ScaleWidth = 8550
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command5
Caption = "save"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3735
Left = 4080
TabIndex = 17
Top = 480
Width = 255
End
Begin VB.Frame Frame1
Caption = "单个明文码组加密"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3975
Left = 4440
TabIndex = 6
Top = 240
Width = 3735
Begin VB.CommandButton Command4
Caption = "解密"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2280
TabIndex = 14
Top = 3000
Width = 975
End
Begin VB.CommandButton Command2
Caption = "加密"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 13
Top = 3000
Width = 975
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 9
Top = 1320
Width = 2175
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
Locked = -1 'True
TabIndex = 8
Top = 2040
Width = 2175
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
MaxLength = 8
TabIndex = 7
Top = 600
Width = 2175
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "密文:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 12
Top = 2160
Width = 735
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "明文:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 11
Top = 1440
Width = 735
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "口令:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 10
Top = 720
Width = 735
End
End
Begin VB.CommandButton Command1
Caption = "解密"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4440
TabIndex = 4
Top = 4320
Width = 2295
End
Begin VB.TextBox Text6
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3855
Left = 4440
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 3
Top = 4920
Width = 3735
End
Begin VB.TextBox Text5
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3735
Left = 360
MultiLine = -1 'True
TabIndex = 2
Top = 480
Width = 3735
End
Begin VB.TextBox Text4
BackColor = &H00C00000&
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 3855
Left = 360
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 1
Top = 4920
Width = 3735
End
Begin VB.CommandButton Command3
BackColor = &H00FF0000&
Caption = "加密"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1800
TabIndex = 0
Top = 4320
Width = 2295
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "解密后文件:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 6840
TabIndex = 16
Top = 4560
Width = 1440
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "加密后文件:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 360
TabIndex = 15
Top = 4560
Width = 1440
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "原文件:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 360
TabIndex = 5
Top = 120
Width = 960
End
Begin APEXDESLib.ApexDes ApexDes1
Left = 120
Top = 120
_Version = 65536
_ExtentX = 2566
_ExtentY = 2355
_StockProps = 0
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim output(8) As Integer
Dim plainfile As String
Dim cipherfile As String
Dim decipherfile As String
Private Sub Command1_Click()
'解密
Dim fp, op As Integer
Dim readstr, temp As String
Dim i As Integer
Dim plaintext As String
Dim count, filelength As Integer
Dim strng As String
Dim totlestr As String
totlestr = ""
Text6.Text = ""
fp = FreeFile()
Open cipherfile For Binary Access Read As #fp
op = FreeFile()
Open decipherfile For Binary Access Write As #op
temp = ""
endflag = False
count = 1
filelength = LOF(fp)
While (count <= filelength) And (Not endflag)
For i = 0 To 7
output(i) = AscB(" ")
Next i
For i = 0 To 7
output(i) = AscB(InputB(1, fp))
If EOF(fp) Then
endflag = True
Exit For
End If
Next i
ApexDes1.Crypt 0, output(0)
strng = ""
For i = 0 To 7
Put #op, count, CByte(output(i))
strng = strng & ChrB(output(i))
count = count + 1
Next i
totlestr = totlestr & StrConv(strng, vbUnicode)
Wend
Close (fp)
Close (op)
Text6.Text = totlestr
End Sub
Private Sub Command2_Click()
'加密
Dim i As Integer
Dim strng As String
strng = StrConv(Text1.Text, vbFromUnicode)
For i = 0 To 7
If i < (LenB(strng)) Then
output(i) = AscB(MidB(strng, i + 1, 1))
Else
output(i) = AscB(" ")
End If
Next i
ApexDes1.Crypt 1, output(0)
strng = ""
For i = 0 To 7
strng = strng & ChrB(output(i))
Next i
Text2.Text = StrConv(strng, vbUnicode)
End Sub
Private Sub Command3_Click()
'加密
Dim fp, op As Integer
Dim readstr, temp As String
Dim i As Integer
Dim plaintext As String
Dim count, filelength As Integer
Dim strng As String
Text4.Text = ""
Text6.Text = ""
fp = FreeFile()
Open plainfile For Binary Access Read As #fp
op = FreeFile()
Open cipherfile For Binary Access Write As #op
temp = ""
endflag = False
count = 1
filelength = LOF(fp)
While (count <= filelength) And (Not endflag)
For i = 0 To 7
output(i) = 0
Next i
For i = 0 To 7
output(i) = AscB(InputB(1, fp))
If EOF(fp) Then
endflag = True
Exit For
End If
Next i
ApexDes1.Crypt 1, output(0)
strng = ""
For i = 0 To 7
Put #op, count, CByte(output(i))
strng = strng & ChrB(output(i))
count = count + 1
Next i
Text4.Text = Text4.Text & strng
Wend
Close (fp)
Close (op)
End Sub
Private Sub Command4_Click()
'解密
Dim i As Integer
Dim strng As String
ApexDes1.Crypt 0, output(0)
strng = ""
For i = 0 To 7
strng = strng & ChrB(output(i))
Next i
Text2.Text = StrConv(strng, vbUnicode)
End Sub
Private Sub Command5_Click()
'保存文本
Dim fp As Integer
fp = FreeFile()
Open plainfile For Output As #fp
Print #fp, Text5.Text
Close (fp)
End Sub
Private Sub Form_Load()
Dim fp As Integer
Dim readstr As String
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
plainfile = App.Path & "\DESText.txt"
cipherfile = App.Path & "\cipher.txt"
decipherfile = App.Path & "\DESText1.txt"
Text3.Text = "01234567"
Text2.Text = ""
Text1.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
fp = FreeFile()
Open plainfile For Input As #fp
While Not EOF(fp)
Input #fp, readstr
Text5.Text = Text5.Text & readstr & Chr(13) & Chr(10)
Wend
Close (fp)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -