vb程序设计 加密解密字符串

2024年11月22日 16:01
有1个网友回答
网友(1):

'对文本框的MultiLine=True和岩态ScrollBars=3的设置,要在属性窗口中进行,在第坦好一个文本框中输入回车,即粗信源可执行

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim n As Integer, i As Integer, pwd As String, oByte() As Byte, temp() As String
If KeyAscii = 13 Then
i = 0
pwd = Text1
n = Len(pwd)
ReDim oByte(0 To n - 1), temp(0 To n - 1)
Do While i < n
oByte(i) = Asc(Mid(pwd, i + 1, 1))
oByte(i) = 21 Xor oByte(i)
temp(i) = Chr(oByte(i))
i = i + 1
Loop
Text2 = Join(temp, "")

i = 0
pwd = Text2
n = Len(pwd)
ReDim oByte(0 To n - 1), temp(0 To n - 1)
Do While i < n
oByte(i) = Asc(Mid(pwd, i + 1, 1))
oByte(i) = 21 Xor oByte(i)
temp(i) = Chr(oByte(i))
i = i + 1
Loop
Text3 = Join(temp, "")
End If

End Sub