FileDocCategorySizeDatePackage
RC4.javaAPI DocJCIFS 1.3.17 API1792Tue Oct 18 15:26:24 BST 2011jcifs.util

RC4

public class RC4 extends Object

Fields Summary
byte[]
s
int
i
int
j
Constructors Summary
public RC4()

    
public RC4(byte[] key)

        init(key, 0, key.length);
    
Methods Summary
public voidinit(byte[] key, int ki, int klen)

        s = new byte[256];

        for (i = 0; i < 256; i++)
            s[i] = (byte)i;

        for (i = j = 0; i < 256; i++) {
            j = (j + key[ki + i % klen] + s[i]) & 0xff;
            byte t = s[i];
            s[i] = s[j];
            s[j] = t;
        }

        i = j = 0;
    
public voidupdate(byte[] src, int soff, int slen, byte[] dst, int doff)

        int slim;

        slim = soff + slen;
        while (soff < slim) {
            i = (i + 1) & 0xff;
            j = (j + s[i]) & 0xff;
            byte t = s[i];
            s[i] = s[j];
            s[j] = t;
            dst[doff++] = (byte)(src[soff++] ^ s[(s[i] + s[j]) & 0xff]);
        }