关于vb.net显示说明的信息( 三 )


plaintext = StrConv(textline, vbFromUnicode)
再对plaintext做加密,其结果就一样了 。
举例(按行做加密和解密运算,算法是AES+Base64):
[vb] view plain copy
Status = "Encrypting File"
Open FileName For Input As #1' 打开输入文件 。
Open FileName2 For Output As #2' 打开输出文件 。
Do While Not EOF(1)
Line Input #1, TextLine
plaintext = StrConv(TextLine, vbFromUnicode)
Status = "Encrypting Data"
m_Rijndael.SetCipherKey pass, KeyBits
m_Rijndael.ArrayEncrypt plaintext, ciphertext, 0
Status = "Converting Text to Base64"
TextLine = Base64Encode(ciphertext)
Status = ""
Print #2, TextLine' 将字符串写入文件 。
Loop
Close
[vb] view plain copy
Status = "Decrypting File"
Open FileName For Input As #1' 打开输入文件 。
Open FileName2 For Output As #2' 打开输出文件 。
Do While Not EOF(1)
Line Input #1, TextLine
Status = "Converting Base64 to Text"
ciphertext = Base64Decode(TextLine)
Status = "Decrypting Data"
m_Rijndael.SetCipherKey pass, KeyBits
If m_Rijndael.ArrayDecrypt(plaintext, ciphertext, 0)0 Then
Status = ""
Exit Sub
End If
TextLine = StrConv(plaintext, vbUnicode)
For i = 0 To UBound(plaintext)
Debug.Print plaintext(i)
Next i
k = InStr(1, TextLine, Chr(0), vbBinaryCompare)
If k0 Then TextLine = Left(TextLine, k - 1)'截掉加密时补的0
MsgBox TextLine"end"
Status = ""
Print #2, TextLine' 将字符串写入文件 。
Loop
Close
vb.net显示说明的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、vb.net显示说明的信息别忘了在本站进行查找喔 。

推荐阅读