DBAbstract API Documentation

ro.raducora.utils.encryption
Class RC4

java.lang.Object
  |
  +--ro.raducora.utils.encryption.RC4

public final class RC4
extends java.lang.Object

This class implements the RC4 (TM) stream cipher.


Constructor Summary
RC4()
          Constructs an RC4 cipher object, in the UNINITIALIZED state.
 
Method Summary
 java.lang.Object clone()
          Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons).
 int engineBlockSize()
          SPI : Returns the length of an input block, in bytes.
 void engineInitDecrypt(byte[] key)
          SPI : Initializes this cipher for decryption, using the specified key.
 void engineInitEncrypt(byte[] key)
          SPI : Initializes this cipher for encryption, using the specified key.
protected  int engineUpdate(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)
          SPI : This is the main engine method for updating data.
 boolean getState()
           
 void rc4(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)
          RC4 encryption/decryption.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RC4

public RC4()
Constructs an RC4 cipher object, in the UNINITIALIZED state.

Method Detail

getState

public boolean getState()
Returns:
true for encrypt false for decrypt

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons).

Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException

engineBlockSize

public int engineBlockSize()
SPI : Returns the length of an input block, in bytes.

Returns:
the length in bytes of an input block for this cipher.

engineInitEncrypt

public void engineInitEncrypt(byte[] key)
                       throws java.security.InvalidKeyException
SPI : Initializes this cipher for encryption, using the specified key.

Parameters:
key - the key to use for encryption.
Throws:
java.security.InvalidKeyException - if the key is invalid.

engineInitDecrypt

public void engineInitDecrypt(byte[] key)
                       throws java.security.InvalidKeyException
SPI : Initializes this cipher for decryption, using the specified key.

Parameters:
key - the key to use for decryption.
Throws:
java.security.InvalidKeyException - if the key is invalid.

engineUpdate

protected int engineUpdate(byte[] in,
                           int inOffset,
                           int inLen,
                           byte[] out,
                           int outOffset)
SPI : This is the main engine method for updating data.

in and out may be the same array, and the input and output regions may overlap.

Parameters:
in - the input data.
inOffset - the offset into in specifying where the data starts.
inLen - the length of the subarray.
out - the output array.
outOffset - the offset indicating where to start writing into the out array.
Returns:
the number of bytes written.

rc4

public void rc4(byte[] in,
                int inOffset,
                int inLen,
                byte[] out,
                int outOffset)
RC4 encryption/decryption. The input and output regions are assumed not to overlap.

Parameters:
in - the input data.
inOffset - the offset into in specifying where the data starts.
inLen - the length of the subarray.
out - the output array.
outOffset - the offset indicating where to start writing into the out array.

DBAbstract API Documentation

© Copyright Radu Coravu 2002 - 2004.