📄 v6j06-14字符加密.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "字符加密"
ClientHeight = 3270
ClientLeft = 1110
ClientTop = 1515
ClientWidth = 5970
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3270
ScaleWidth = 5970
Begin VB.CommandButton cmdCls
Caption = "清屏"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 6
Top = 2160
Width = 975
End
Begin VB.TextBox txtRecode
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1560
TabIndex = 5
Text = " "
Top = 1440
Width = 3375
End
Begin VB.CommandButton cmdRecode
Caption = "解密"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 4
Top = 1440
Width = 975
End
Begin VB.TextBox txtCode
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1560
TabIndex = 3
Text = " "
Top = 720
Width = 3375
End
Begin VB.CommandButton cmdCode
Caption = "加密"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 2
Top = 720
Width = 975
End
Begin VB.TextBox txtInput
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 1560
TabIndex = 1
Text = " "
Top = 120
Width = 3375
End
Begin VB.Label Labinput
Caption = "输入字符串"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 0
Top = 120
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strInput$, Code$, Record$, c As String * 1
Dim i%, length%, iAsc%
Private Sub cmdcls_Click() '清屏
txtCode.Text = ""
txtRecode.Text = ""
txtInput.Text = ""
End Sub
Private Sub cmdcode_Click() '加密
Dim strInput$, Code$, Record$, c As String * 1
Dim i%, length%, iAsc%
strInput = txtInput.Text
length = Len(RTrim(strInput)) '去掉字符串右边的空格,求真正的长度
Code = ""
For i = 1 To length
c = Mid$(strInput, i, 1) '取第i个字符
Select Case c
Case "A" To "Z" '大写字母加序数5加密
iAsc = Asc(c) + 5
If iAsc > Asc("Z") Then iAsc = iAsc - 26 '加密后字母超过Z
Code = Code + Chr$(iAsc)
Case "a" To "z"
iAsc = Asc(c) + 5 '小写字母加序数5加密
If iAsc > Asc("z") Then iAsc = iAsc - 26
Code = Code + Chr$(iAsc)
Case Else '当第i个字符为其它字符时不加密,与加密字符串的前i-1个字符连接
Code = Code + c
End Select
Next i
txtCode.Text = Code '显示加密后的字符串
End Sub
Private Sub cmdrecode_Click() '解密与加密正好逆处理
Code = txtCode.Text
i = 1
recode = ""
length = Len(RTrim(Code)) '若还未加密,不能解密,出错
If length = 0 Then J = MsgBox("先加密再解密", 48, "解密出错")
Do While (i <= length)
c = Mid$(Code, i, 1)
If (c >= "A" And c <= "Z") Then
iAsc = Asc(c) - 5
If iAsc < Asc("A") Then iAsc = iAsc + 26
recode = Left$(recode, i - 1) + Chr$(iAsc)
ElseIf (c >= "a" And c <= "z") Then
iAsc = Asc(c) - 5
If iAsc < Asc("a") Then iAsc = iAsc + 26
recode = Left$(recode, i - 1) + Chr$(iAsc)
Else
recode = Left$(recode, i - 1) + c
End If
i = i + 1
Loop
txtRecode.Text = recode
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -