Code:
stock RC4(const String:input[], const String:pwd[], String:output[],maxlen)
{
decl pwd_len,str_len,i,j,a,k;
decl key[256];
decl box[256];
decl tmp;
pwd_len = strlen(pwd);
str_len = strlen(input);
if(pwd_len > 0 && str_len > 0)
{
for(i=0;i<256;i++)
{
key[i] = pwd[i%pwd_len];
box[i]=i;
}
i=0;
j=0;
for(;i<256;i++)
{
j = (j + box[i] + key[i]) % 256;
tmp = box[i];
box[i] = box[j];
box[j] = tmp;
}
i=0;
j=0;
a=0;
for(;i<str_len;i++)
{
a = (a + 1) % 256;
j = (j + box[a]) % 256;
tmp = box[a];
box[a] = box[j];
box[j] = tmp;
k = box[((box[a] + box[j]) % 256)];
FormatEx(output,maxlen,"%s%02x",output,input[i] ^ k);
}
}
}
example:
Code:
decl String:output[256];
RC4("1qazxsw23edcVFR$%TGBNHY^&UJM","4rfvbgt5^YHN",output,256);
PrintToServer("%s",output);
dbc57922b7f3d8628083960e0a76094bde07ab6b3d47d4303d5ff071
it allow you to encrypt data in server, then send data to web server or use socket extensions to send out.
You can decrypt the data in web page.
The input ONLY support character(a-z,A-Z), number(0-9), symbol.
The current problem is can not convert a correct any unicode character to integer, and can not get a correct strinf length from unicode character.
if someone can modify this, that can work in any input data and add a decryption inside would be good