📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "加密"
ClientHeight = 7275
ClientLeft = 60
ClientTop = 450
ClientWidth = 8700
LinkTopic = "Form1"
ScaleHeight = 7275
ScaleWidth = 8700
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "解密"
Height = 615
Left = 30
TabIndex = 3
Top = 6420
Width = 2175
End
Begin VB.CommandButton Command1
Caption = "加密"
Height = 615
Left = 6360
TabIndex = 2
Top = 6420
Width = 2175
End
Begin VB.TextBox Text1
Height = 3075
Index = 1
Left = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Text = "Form1.frx":0000
Top = 3240
Width = 8505
End
Begin VB.TextBox Text1
Height = 3075
Index = 0
Left = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Text = "Form1.frx":0006
Top = 30
Width = 8505
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim S() As String
S() = Split(Text1(0), vbCrLf)
For o1 = 0 To UBound(S())
S(o1) = cipher(S(o1))
Next
Text1(1) = Join(S(), vbCrLf)
End Sub
Function cipher(stext As String) '加密程序
Const min_asc = 32
Const max_asc = 126
Const num_asc = max_asc - min_asc + 1
Dim offset As Long
Dim strlen As Integer
Dim i As Integer
Dim ch As Integer
offset = 123
Rnd (-1)
Randomize (offset)
strlen = Len(stext)
For i = 1 To strlen
ch = Asc(Mid(stext, i, 1))
If ch >= min_asc And ch <= max_asc Then
ch = ch - min_asc
offset = Int((num_asc + 1) * Rnd())
ch = ((ch + offset) Mod num_asc)
ch = ch + min_asc
ptext = ptext & Chr(ch)
End If
Next i
cipher = ptext
End Function
Function decipher(stext As String) '解密程序
Const min_asc = 32
Const max_asc = 126
Const num_asc = max_asc - min_asc + 1
Dim offset As Long
Dim strlen As Integer
Dim i As Integer
Dim ch As Integer
offset = 123
Rnd (-1)
Randomize (offset)
strlen = Len(stext)
For i = 1 To strlen
ch = Asc(Mid(stext, i, 1))
If ch >= min_asc And ch <= max_asc Then
ch = ch - min_asc
offset = Int((num_asc + 1) * Rnd())
ch = ((ch - offset) Mod num_asc)
If ch < 0 Then
ch = ch + num_asc
End If
ch = ch + min_asc
ptext = ptext & Chr(ch)
End If
Next i
decipher = ptext
End Function
Private Sub Command2_Click()
Dim S() As String
S() = Split(Text1(0), vbCrLf)
For o1 = 0 To UBound(S())
S(o1) = decipher(S(o1))
Next
Text1(1) = Join(S(), vbCrLf)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -