给自己一点时间接受自己,爱自己,趁着下午茶的时间来学习图老师推荐的加解密文本地函数,过去的都会过去,迎接崭新的开始,释放更美好的自己。
【 tulaoshi.com - 编程语言 】
Private Sub Comman1_Click()
Dim str1, str2, str3 As String
str1 = "王宇虹"
str2 = Encrypt(str1, 188, 24)
MsgBox str2
str3 = Encrypt(str2, 188, 24)
MsgBox str3
End Sub
Private Function Encrypt(ByVal strSource As String, ByVal Key1 As Byte, _
ByVal Key2 As Integer) As String
Dim bLowData As Byte
Dim bHigData As Byte
Dim i As Integer
Dim strEncrypt As String
Dim strChar As String
For i = 1 To Len(strSource)
'从待加(解)密字符串中取出一个字符
strChar = Mid(strSource, i, 1)
' 取字符的低字节和Key1进行异或运算
bLowData = AscB(MidB(strChar, 1, 1)) Xor Key1
'取字符的高字节和K2进行异或运算
bHigData = AscB(MidB(strChar, 2, 1)) Xor Key2
'将运算后的数据合成新的字符
strEncrypt = strEncrypt & ChrB(bLowData) & ChrB(bHigData)
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)Next
Encrypt = strEncrypt
End Function
来源:http://www.tulaoshi.com/n/20160219/1615407.html