Raised This Month: $12 Target: $400
 3% 

[Stock] RC4 encryption


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raydan
Senior Member
Join Date: Aug 2006
Old 04-02-2008 , 06:56   [Stock] RC4 encryption
Reply With Quote #1

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

Last edited by raydan; 04-03-2008 at 09:43.
raydan is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode