Hi Everyone,
We have an encryption function that was written in another language that we
needed translated to PHP.
Here's the function:
function rc4 pText, pKey
-- initialize
repeat with i = 0 to 255
put i into S1[i]
end repeat
put 0 into i
repeat with n = 0 to 255
add 1 to i
if i > length(pkey) then put 1 into i
put chartonum(char i of pKey) into S2[n]
end repeat
put 0 into j
repeat with i = 0 to 255
put (j + S1[i] + S2[i]) mod 256 into j
put S1[i] into temp
put S1[j] into S1[i]
put temp into S1[j]
end repeat
-- encrypt/decrypt
put 0 into i ; put 0 into j
repeat for each char c in pText
put chartonum(c) into tChar
put (i + 1) mod 256 into i
put (j + S1[i]) mod 256 into j
put S1[i] into temp
put S1[j] into S1[i]
put temp into S1[j]
put (S1[i] + S1[j]) mod 256 into t
put S1[t] into K
put numtochar(tChar bitXor K) after tOutput
end repeat
return tOutput
end rc4
Can anyone help us with this? We don't mind paying via PayPal :)
Thanks!
grace