以下是根据学号末2位加密、解密的VB程序:
Private Sub Form_Click()
x = Val(Right(Text1.Text, 2)) '取学号末2位
'以下是加密
s = Text2.Text
s1 = s
For i = 1 To Len(s)
c = Mid(s1, i, 1)
Mid(s1, i, 1) = Chr(Asc(c) Xor x)
Next i
Text3.Text = s1
'以下是解密
s = s1
For i = 1 To Len(s)
c = Mid(s, i, 1)
Mid(s, i, 1) = Chr(Asc(c) Xor x)
Next i
Text4.Text = s
End Sub