Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void RC4(char*bytes,char*key)
- {
- char* s = new char[256];
- char* k = new char[256];
- char temp;
- int i, j;
- for (i = 0; i < 256; i++)
- {
- s[i] = (char)i;
- k[i] = key[i % sizeof(key)];
- }
- j = 0;
- for (i = 0; i < 256; i++)
- {
- j = (j + s[i] + k[i]) % 256;
- temp = s[i];
- s[i] = s[j];
- s[j] = temp;
- }
- i = j = 0;
- for (int x = 0; x < sizeof(bytes); x++)
- {
- i = (i + 1) % 256;
- j = (j + s[i]) % 256;
- temp = s[i];
- s[i] = s[j];
- s[j] = temp;
- int t = (s[i] + s[j]) % 256;
- bytes[x] ^= s[t];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment