ش | ی | د | س | چ | پ | ج |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Function fRunRC4(sMessage, strKey) As String Dim kLen, x, y, i, j, temp Dim s(256), k(256)
'Init keystream
kLen = Len(strKey)For i = 0 To 255s(i) = ik(i) = Asc(Mid(strKey, (i Mod kLen) + 1, 1))Nextj = 0For i = 0 To 255j = (j + k(i) + s(i)) Mod 255temp = s(i)s(i) = s(j)s(j) = tempNext'Drop n bytes from keystreamx = 0y = 0For i = 1 To 3072x = (x + 1) Mod 255y = (y + s(x)) Mod 255temp = s(x)s(x) = s(y)s(y) = tempNext'Encode/DecodeFor i = 1 To Len(sMessage)x = (x + 1) Mod 255y = (y + s(x)) Mod 255temp = s(x)s(x) = s(y)s(y) = tempfRunRC4 = fRunRC4 & Chr(s((s(x) + s(y)) Mod 255) Xor Asc(Mid(sMessage, i, 1)))Next
End Function