netapp.manage
Class ARCFour

java.lang.Object
  extended bynetapp.manage.ARCFour

public class ARCFour
extends java.lang.Object

A utility class implementing ARCFOUR (the alleged RC4 algorithm) for encryption of a data stream. Until 1994 RC4 was a trade secret of RSA Data Security, Inc, when it was released anonymously to a mailing list. Because there is no proof that the leaked version was in fact RC4 and because "RC4" is a trademark, it is called "ARCFOUR", short for "Allegedly RC4". This version is ported to java from the source in zephyr's src/libnetapp/na.c. This algorithm has the property that calling crypt() with the same password on an encrypted value returns the original text.


Constructor Summary
ARCFour()
          Constructor using a default key.
ARCFour(java.lang.String key)
          Constructor using a key you specify.
 
Method Summary
 char[] crypt(char[] input)
          Encrypts or decrypt an input buffer.
 char[] crypt(char[] input, char[] output)
          Encrypts or decrypt.
 char[] crypt(java.lang.String input)
          Encrypts or decrypt a string.
static java.lang.String decodeAndDecrypt(java.lang.String input)
          Convenience method that undoes the encoding and encrypt from encryptAndEncode() using the default key.
static java.lang.String encryptAndEncode(java.lang.String input)
          Convenience method that both encrypts and base-16 encodes a string using the default key.
 void init()
          Initializes the crypto engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ARCFour

public ARCFour()
Constructor using a default key.


ARCFour

public ARCFour(java.lang.String key)
Constructor using a key you specify.

Method Detail

init

public void init()
Initializes the crypto engine. Call this method before each unique encryption or decryption operation.


crypt

public char[] crypt(char[] input,
                    char[] output)
Encrypts or decrypt. This can be called multiple times to encrypt a stream of data. Be sure to call init() before each unique encryption or decryption operation.

Parameters:
input - characters to encrypt; this may be null
output - location to store the encrypted result
Returns:
the encrypted result

crypt

public char[] crypt(char[] input)
Encrypts or decrypt an input buffer.

Parameters:
input - characters to encrypt; this may be null
Returns:
the encrypted result

crypt

public char[] crypt(java.lang.String input)
Encrypts or decrypt a string.

Parameters:
input - string to encrypt; this may be null
Returns:
the encrypted result

encryptAndEncode

public static java.lang.String encryptAndEncode(java.lang.String input)
Convenience method that both encrypts and base-16 encodes a string using the default key.

Parameters:
input - plaintext to encrypt; this may be null
Returns:
the encrypted, encoded string

decodeAndDecrypt

public static java.lang.String decodeAndDecrypt(java.lang.String input)
Convenience method that undoes the encoding and encrypt from encryptAndEncode() using the default key.

Parameters:
input - encrypted/encoded data to decode; this may be null
Returns:
the decoded, decrypted (plaintext) string