加密程序为何+32 才显示可打印字符
Private Sub Command1_Click()cleartext = Text1.Text
If Len(cleartext) = 0 Then
cleartext = "": Text2.Text = ""
Exit Sub
End If
Dim tmpbuf() As Byte
Dim inval As Long, xorval As Long, outval As Long
Dim i As Long, j As Long
Randomize (Rnd((-1) * Abs(keycode) * Len(cleartext))) '生成固定序列组
tmpbuf = StrConv(cleartext, vbFromUnicode) '-----------tmpbuf转成西文单字节
For i = LBound(tmpbuf) To UBound(tmpbuf)
xorval = Int(128 * Rnd) '----------------------------固定的整数组,0-128之间不含128
inval = Int(tmpbuf(i)) ' ---------------------------对原码的ANSI码提取码的字符值
tmpbuf(i) = converttoprintablechar(xorval, inval Xor xorval) '对输入的密码进行加密inval Xor xorval
Next i
ciphertext = StrConv(tmpbuf, vbUnicode)
Text2.Text = ciphertext '加密后的字符串
End Sub
Private Function converttoprintablechar(ByVal xorval As Long, ByVal calaval As Long) As Byte
Dim k As Long, i As Long
For i = 32 To 126 '-------------------------可打印字符是32-126之间,含32,126
If (i Xor xorval) < calaval Then '可打印字符与固定序列随机数逐个XOR
k = k + 1
End If
Next i
converttoprintablechar = CByte(32 + k) '------------------为什么+32
End Function
以上程序是加密程序,返回值为什么要+32???不解????