加解密文本的函数

时间:2009-07-11 01:45:09   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:rivate 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(strSour...
  正文:

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



来源:http://www.002pc.com/master/College/Database/Access/2009-07-11/10030.html

收藏到:

关于《加解密文本的函数》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='98' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='98' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td