class RC4Cipher
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
b |
private int |
c |
private int[] |
salt |
Constructor and Description |
---|
RC4Cipher()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private static int |
fixByte(byte aByte)
This will ensure that the value for a byte >=0.
|
void |
setKey(byte[] key)
This will reset the key to be used.
|
private static void |
swap(int[] data,
int firstIndex,
int secondIndex)
This will swap two values in an array.
|
void |
write(byte[] data,
int offset,
int len,
java.io.OutputStream output)
This will encrypt and write the data.
|
void |
write(byte[] data,
java.io.OutputStream output)
This will encrypt and write the data.
|
void |
write(byte aByte,
java.io.OutputStream output)
This will encrypt and write the next byte.
|
void |
write(java.io.InputStream data,
java.io.OutputStream output)
This will encrypt and write the data.
|
public void setKey(byte[] key)
key
- The RC4 key used during encryption.private static int fixByte(byte aByte)
aByte
- The byte to test against.private static void swap(int[] data, int firstIndex, int secondIndex)
data
- The array to swap from.firstIndex
- The index of the first element to swap.secondIndex
- The index of the second element to swap.public void write(byte aByte, java.io.OutputStream output) throws java.io.IOException
aByte
- The byte to encrypt.output
- The stream to write to.java.io.IOException
- If there is an error writing to the output stream.public void write(byte[] data, java.io.OutputStream output) throws java.io.IOException
data
- The data to encrypt.output
- The stream to write to.java.io.IOException
- If there is an error writing to the output stream.public void write(java.io.InputStream data, java.io.OutputStream output) throws java.io.IOException
data
- The data to encrypt.output
- The stream to write to.java.io.IOException
- If there is an error writing to the output stream.public void write(byte[] data, int offset, int len, java.io.OutputStream output) throws java.io.IOException
data
- The data to encrypt.offset
- The offset into the array to start reading data from.len
- The number of bytes to attempt to read.output
- The stream to write to.java.io.IOException
- If there is an error writing to the output stream.