com.knowgate.acl
Class RC4

java.lang.Object
  extended by com.knowgate.acl.RC4

public class RC4
extends java.lang.Object

This is a simple implementation of the RC4 (tm) encryption algorithm. The author implemented this class for some simple applications that don't need/want/require the Sun's JCE framework.

But if you are looking for encryption algorithms for a full-blown application, it would be better to stick with Sun's JCE framework. You can find a *free* JCE implementation with RC4 (tm) at Cryptix (http://www.cryptix.org/).

Note that RC4 (tm) is a trademark of RSA Data Security, Inc. Also, if you are within USA, you may need to acquire licenses from RSA to use RC4. Please check your local law. The author is not responsible for any illegal use of this code.


Constructor Summary
RC4(byte[] key)
          Initializes the class with a byte array key.
RC4(java.lang.String key)
          Initializes the class with a string key.
 
Method Summary
 byte[] rc4(byte[] buf)
          RC4 encryption/decryption.
 byte[] rc4(java.lang.String data)
          RC4 encryption/decryption.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RC4

public RC4(java.lang.String key)
    throws java.lang.NullPointerException
Initializes the class with a string key. The length of a normal key should be between 1 and 2048 bits. But this method doens't check the length at all.

Parameters:
key - the encryption/decryption key
Throws:
java.lang.NullPointerException

RC4

public RC4(byte[] key)
    throws java.lang.NullPointerException
Initializes the class with a byte array key. The length of a normal key should be between 1 and 2048 bits. But this method doens't check the length at all.

Parameters:
key - the encryption/decryption key
Throws:
java.lang.NullPointerException
Method Detail

rc4

public byte[] rc4(java.lang.String data)
RC4 encryption/decryption.

Parameters:
data - the data to be encrypted/decrypted
Returns:
the result of the encryption/decryption

rc4

public byte[] rc4(byte[] buf)
RC4 encryption/decryption.

Parameters:
buf - the data to be encrypted/decrypted
Returns:
the result of the encryption/decryption