Sub rc4(message As String, password As String) As String
Dim i As Int
i = 0
Dim j As Int
j = 0
Dim cipher As StringBuilder
cipher.Initialize
Dim returnCipher As String
returnCipher = ""
Dim sbox(256) As Int
Dim key(256) As Int
Dim intLength As Int
intLength = password.Length
Dim a As Int
a = 0
Do While a <= 255
Dim ctmp As Char
ctmp = password.SubString(a Mod intLength)
key(a) = Asc(ctmp)
sbox(a) = a
a = a + 1
Loop
Dim x As Int
x = 0
Dim b As Int
b = 0
Do While b <= 255
x = (x + sbox(b) + key(b)) Mod 256
Dim tempSwap As Int
tempSwap = sbox(b)
sbox(b) = sbox(x)
sbox(x) = tempSwap
b = b + 1
Loop
a = 1
Do While a <= message.Length
Dim itmp As Int
itmp = 0
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
itmp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = itmp
Dim k As Int
k = sbox((sbox(i) + sbox(j)) Mod 256)
Dim ctmp As Char
ctmp = message.Substring(a - 1)
itmp = Asc(ctmp)
Dim cipherby As Int
cipherby = Bit.Xor(itmp, k)
cipher.Append(Chr(cipherby))
a = a + 1
Loop
returnCipher = cipher.ToString
Return returnCipher
End Sub