private function encode(byval s as string) as string '加密
if len(s) = 0 then exit function
dim buff() as byte
buff = strconv(s, vbfromunicode)
dim i as long
dim j as byte
dim k as byte, m as byte
dim mstr as string
mstr= "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
dim outs as string
i = ubound(buff) + 1
outs = space(2 * i)
dim temps as string
for i = 0 to ubound(buff)
randomize time
j = cbyte(5 * (math.rnd()) + 0) '最大产生的随机数只能是5,不能再大了,再大的话,就要多用一个字节
buff(i) = buff(i) xor j
k = buff(i) mod len(mstr)
m = buff(i) \ len(mstr)
m = m * 2 ^ 3 + j
temps = mid(mstr, k + 1, 1) + mid(mstr, m + 1, 1)
mid(outs, 2 * i + 1, 2) = temps
next
encode = outs
end function上面代码里的m = m * 2 ^ 3 + j有什么特别的意义吗?为什么要*8和+j哦?
if len(s) = 0 then exit function
dim buff() as byte
buff = strconv(s, vbfromunicode)
dim i as long
dim j as byte
dim k as byte, m as byte
dim mstr as string
mstr= "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
dim outs as string
i = ubound(buff) + 1
outs = space(2 * i)
dim temps as string
for i = 0 to ubound(buff)
randomize time
j = cbyte(5 * (math.rnd()) + 0) '最大产生的随机数只能是5,不能再大了,再大的话,就要多用一个字节
buff(i) = buff(i) xor j
k = buff(i) mod len(mstr)
m = buff(i) \ len(mstr)
m = m * 2 ^ 3 + j
temps = mid(mstr, k + 1, 1) + mid(mstr, m + 1, 1)
mid(outs, 2 * i + 1, 2) = temps
next
encode = outs
end function上面代码里的m = m * 2 ^ 3 + j有什么特别的意义吗?为什么要*8和+j哦?
http://blog.csdn.net/rainstormmaster/archive/2004/03/30/20346.aspx
Private Function decode(ByVal s As String) As String '解密
On Error GoTo myERR
Dim i As Long
Dim j As Byte
Dim k As Byte
Dim m As Byte
Dim mstr As String
mstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
Dim t1 As String, t2 As String
Dim buff() As Byte
Dim n As Long
n = 0
For i = 1 To Len(s) Step 2
t1 = Mid(s, i, 1)
t2 = Mid(s, i + 1, 1)
k = InStr(1, mstr, t1) - 1
m = InStr(1, mstr, t2) - 1
j = m \ 2 ^ 3
m = m - j * 2 ^ 3
ReDim Preserve buff(n)
buff(n) = j * Len(mstr) + k
buff(n) = buff(n) Xor m
n = n + 1
Next
decode = StrConv(buff, vbUnicode)
Exit Function
myERR:
decode = ""
End Function这个代码里buff(n) 是什么意思啊?还有ReDim Preserve buff(n)、 For i = 1 To Len(s) Step 2、还有其中得到了n是什么呢?