anon.crypto
Class AesEncryption

java.lang.Object
  extended by anon.crypto.AesEncryption

public class AesEncryption
extends java.lang.Object

This class is a wrapper for doing AES encryption stuff.


Field Summary
private  org.bouncycastle.crypto.engines.AESFastEngine m_encryptionInstance
          Stores the used AES encryption algorithm.
 
Constructor Summary
AesEncryption(byte[] a_aesKey)
          Creates a new instance of AesEncryption.
 
Method Summary
 byte[] encrypt(byte[] a_plainData)
          Encrypts one single plain data block and returns the cipher data block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_encryptionInstance

private org.bouncycastle.crypto.engines.AESFastEngine m_encryptionInstance
Stores the used AES encryption algorithm.

Constructor Detail

AesEncryption

public AesEncryption(byte[] a_aesKey)
              throws java.lang.Exception
Creates a new instance of AesEncryption. The size of the key must be 16 bytes (128 bit), 24 bytes (192 bit) or 32 bytes (256 bit). If the key size doesn't fit, an exception is thrown.

Parameters:
a_aesKey - The 128 bit or 192 bit or 256 bit AES key.
Throws:
java.lang.Exception
Method Detail

encrypt

public byte[] encrypt(byte[] a_plainData)
               throws java.lang.Exception
Encrypts one single plain data block and returns the cipher data block. The blocksize is always 16 bytes (128 bit). If the plain data block is shorter than 16 bytes, an exception is thrown, if it is longer, only the first 16 bytes are encrypted and returned in the cipher block.

Parameters:
a_plainData - The plain data block.
Returns:
The cipher data block. The length is always 16 bytes.
Throws:
java.lang.Exception