1 package org.ibex.crypto;
3 package org.ibex.crypto;
5 public class RC4 implements Cipher {
6 private final byte[] s = new byte[256];
10 for(int i=0;i<256;i++) s[i] = (byte)i;
11 for(int i=0,j=0;i<256;i++) {
12 j = (j + (s[i]&0xff) + (k[i%k.length]&0xff))&0xff;
19 public void process(byte[] in, int ip, byte[] out, int op, int len) {
23 for(int i=0;i<len;i++) {
25 y = (y + (s[x]&0xff)) & 0xff;
29 int t = ((s[x]&0xff) + (s[y]&0xff))&0xff;
31 out[op+i] = (byte)((in[ip+i]&0xff)^k);