com.monica.javacom.ciphering
Class AES

java.lang.Object
  |
  +--com.monica.javacom.ciphering.AES

public class AES
extends java.lang.Object

Implements an AES (American Encription Standard, also known as RC6) encoder/decoder, which is the recent standard for symmetric-key-ciphering of digital data. This object uses an AESKey as the encoding/decoding key, generated by an AESKeyGenerator. As the main functionality, the coder gets a String which contains the initial data, and returns the coded representation of this String.

See Also:
AESKey, AESKeyGenerator

Constructor Summary
AES(AESKey in_key, int in_numberOfRounds)
          Constructs a new AES encoder/decoder object.
 
Method Summary
 java.lang.String decode(java.lang.String text)
          Decodes the specified String.
 java.lang.String encode(java.lang.String text)
          Encodes the specified String.
 AESKey getKey()
          Returns the AESKey of this AES object.
 int getNumberOfRounds()
          Returns the number of rounds of this AES object.
 void setKey(AESKey in_key)
          Sets the AESKey of this object.
 void setNumberOfRounds(int in_numberOfRounds)
          Sets the number of rounds of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AES

public AES(AESKey in_key,
           int in_numberOfRounds)
    throws BadInputValueException
Constructs a new AES encoder/decoder object.
Parameters:
in_key - the AESKey that the AES will use to encode/decode
in_numberOfRounds - the number of runds defined in the AES algorithm - default: 20
Throws:
BadInputValueException - the in_numberOfRounds parameter must be between 1 and 256
Method Detail

encode

public java.lang.String encode(java.lang.String text)
                        throws ZeroLengthStringException
Encodes the specified String.
Parameters:
text - the input text which has to be encoded
Returns:
the encoded representation of the input text
Throws:
ZeroLengthStringException - input string must not be empty

decode

public java.lang.String decode(java.lang.String text)
                        throws ZeroLengthStringException
Decodes the specified String.
Parameters:
text - the encoded text which must be the result of the encode() function of an AES object whith the same key, that this AES is working with.
Returns:
the decoded representation of the encoded text, the input text of the encoding algorithm
Throws:
ZeroLengthStringException - input string must not be empty and the length of it must be a multiple of 17

getKey

public AESKey getKey()
Returns the AESKey of this AES object.
Returns:
the AESKey, that this object is working with

getNumberOfRounds

public int getNumberOfRounds()
Returns the number of rounds of this AES object.
Returns:
the value, that this object is working with as number of runds definded in the AES algorithm.

setKey

public void setKey(AESKey in_key)
Sets the AESKey of this object.
Parameters:
in_key - the new AESKey that this AES object should use

setNumberOfRounds

public void setNumberOfRounds(int in_numberOfRounds)
                       throws BadInputValueException
Sets the number of rounds of this object.
Parameters:
in_numberOfRounds - the number of runds defined in the AES algorithm
Throws:
BadInputValueException - the in_numberOfRounds parameter must be between 1 and 256