这是我搜来的一段加密与解密的程序,第一次加密,第2次解密。我文件中的大部分内容都能正确加密与解密,唯独代码后面附带的文字不行。我不是科班出身。对于原理也模模糊糊。请大师给看看,怎么解决一下。
'Option Explicit
Private Sub jiami(str1 As String)
Text1 = ""
Text2 = ""
If Dir(App.Path + "\" & str1 & ".txt") <> "" Then
Open App.Path + "\" & str1 & ".txt" For Input As #1 '打开文件
Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
S = Text1
For i = 1 To Len(S) - 1
temp = Mid(S, i, 1)
List1.AddItem Mid(S, i, 1)
List2.AddItem Asc(temp)
List3.AddItem Asc(temp) Xor 1
List4.AddItem Chr(Asc(temp) Xor 1)
temp = Chr(Asc(temp) Xor 1)
List5.AddItem temp
t = t + temp
Next
Text2 = Mid(t, 1, Len(t) - 2)
Open App.Path + "\" & str1 & ".txt" For Output As #1 '清除旧的数据,写入新的数据
Print #1, Text2.Text
Close #1
End If
End Sub
Private Sub Command1_Click()
Call jiami("普通文件")
End Sub
将后面附带的文字存为 普通文件.txt
佝偻病
口服避孕药【会使GGT值增高20%。】
十二指肠溃疡
弥漫性肺间质纤维化
运行效果图

请大师给看看问题在哪里?为什么几个汉字加密后的字符是?呢。怎么改改呢。
'Option Explicit
Private Sub jiami(str1 As String)
Text1 = ""
Text2 = ""
If Dir(App.Path + "\" & str1 & ".txt") <> "" Then
Open App.Path + "\" & str1 & ".txt" For Input As #1 '打开文件
Text1.Text = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
S = Text1
For i = 1 To Len(S) - 1
temp = Mid(S, i, 1)
List1.AddItem Mid(S, i, 1)
List2.AddItem Asc(temp)
List3.AddItem Asc(temp) Xor 1
List4.AddItem Chr(Asc(temp) Xor 1)
temp = Chr(Asc(temp) Xor 1)
List5.AddItem temp
t = t + temp
Next
Text2 = Mid(t, 1, Len(t) - 2)
Open App.Path + "\" & str1 & ".txt" For Output As #1 '清除旧的数据,写入新的数据
Print #1, Text2.Text
Close #1
End If
End Sub
Private Sub Command1_Click()
Call jiami("普通文件")
End Sub
将后面附带的文字存为 普通文件.txt
佝偻病
口服避孕药【会使GGT值增高20%。】
十二指肠溃疡
弥漫性肺间质纤维化
运行效果图

请大师给看看问题在哪里?为什么几个汉字加密后的字符是?呢。怎么改改呢。



