首页 > 开发 > 综合 > 正文

加解密文本的函数

2024-07-21 02:13:28
字体:
来源:转载
供稿:网友
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)

next
encrypt = strencrypt
end function

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表