编写一个小程序,可以对输入的一段英文字符串进行加密和解密,加密算法中需要使

2025-01-07 03:07:29
推荐回答(1个)
回答1:

用VB编的
Option Explicit

'加密
Private Sub Command1_Click()
Text2 = ""
Dim i As Long
For i = 1 To Len(Text1)
Text2 = Text2 & Chr(Asc(Mid(Text1, i, 1)) - 300)
Next
Text1 = ""
End Sub

'解密
Private Sub Command2_Click()
Text1 = ""
Dim i As Long
For i = 1 To Len(Text2)
Text1 = Text1 & Chr(Asc(Mid(Text2, i, 1)) + 300)
Next

End Sub

'原字符串
Private Sub Form_Load()
Text1 = "中华人民共和国"
Text2 = ""
End Sub