![RC4 加密算法asp版 RC4 加密算法asp版](/default/index/img?u=aHR0cDovL2NvbW1vbi5jbmJsb2dzLmNvbS9pbWFnZXMvY29weWNvZGUuZ2lm)
1 Function RC4(data, Key)
2 Dim s(256), k(256), outstr, Acii, j, tst, xre1, xre2, temp, x, t, y, qwe, zxc
3 For i = 1 To 256
4 s(i) = i - 1
5 Next
6 j = 1
7 For i = 1 To 256
8 dex = dex + 1
9 If j > Len(Key) Then
10 j = 1
11 End If
12 Acii = Asc(Mid(Key, j, 1))
13 If Acii < 0 Then
14 tst = Hex(Acii)
15 xre1 = Mid(tst, 1, 2)
16 xre2 = Mid(tst, 3, 2)
17 k(i) = Int("&H" & xre1)
18 k(i + 1) = Int("&H" & xre2)
19 i = i + 1
20 Else
21 k(i) = Acii
22 End If
23 j = j + 1
24 Next
25 j = 0
26 For i = 1 To 256
27 j = (j + s(i) + k(i)) Mod 256 + 1
28 temp = s(i)
29 s(i) = s(j)
30 s(j) = temp
31 Next
32 j = 0
33 For i = 1 To Len(data)
34 x = (x + 1) Mod 256 + 1
35 j = (j + s(x)) Mod 256 + 1
36 temp = s(x)
37 s(x) = s(j)
38 s(j) = temp
39 t = (s(x) + s(j) Mod 256) Mod 256 + 1
40 y = s(t)
41 Acii = Asc(Mid(data, i, 1))
42 If Acii < 0 Then
43 tst = Hex(Acii)
44 qwe = qwe + 1
45 If qwe >= 2 Then
46 zxc = Int("&H" & Mid(tst, 3, 2))
47 qwe = 0
48 Else
49 zxc = Int("&H" & Mid(tst, 1, 2))
50 i = i -1
51 End If
52 Else
53 zxc = Acii
54 End If
55 outstr = outstr & Bitsor(zxc, y)
56 Next
57 RC4 = outstr
58 End Function
59
60 Function Bitsor(x, y)
61 Dim Mx, Hx, Wx
62 Mx = 0
63 Hx = 0
64 Wx = 0
65 Mx = x And y
66 Mx = Mx * 2
67 Hx = Hex(X + y - Mx)
68 If Len(Hx) > 1 Then
69 Wx = Hx
70 Else
71 Wx = "0" & Hx
72 End If
73 Bitsor = Wx
74 End Function
![RC4 加密算法asp版 RC4 加密算法asp版](/default/index/img?u=aHR0cDovL2NvbW1vbi5jbmJsb2dzLmNvbS9pbWFnZXMvY29weWNvZGUuZ2lm)