org.smslib.crypto
Class AESKey
java.lang.Object
org.smslib.crypto.AKey
org.smslib.crypto.ASymmetricKey
org.smslib.crypto.AESKey
public class AESKey
- extends ASymmetricKey
Class representing an AES algorithm encryption key.
The class is based on standard JDK AES implementation (128 bit key).
Constructor Summary |
AESKey()
|
AESKey(javax.crypto.spec.SecretKeySpec key)
|
Method Summary |
byte[] |
decrypt(byte[] message)
Message decryption. |
byte[] |
encrypt(byte[] message)
Message encryption. |
javax.crypto.spec.SecretKeySpec |
generateKey()
Key generation. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AESKey
public AESKey()
throws java.security.NoSuchAlgorithmException
- Throws:
java.security.NoSuchAlgorithmException
AESKey
public AESKey(javax.crypto.spec.SecretKeySpec key)
generateKey
public javax.crypto.spec.SecretKeySpec generateKey()
throws java.security.NoSuchAlgorithmException
- Description copied from class:
ASymmetricKey
- Key generation.
The method should be implemented in the descending classes, according to
the implementation.
- Specified by:
generateKey
in class ASymmetricKey
- Returns:
- The generated encryption key.
- Throws:
java.security.NoSuchAlgorithmException
encrypt
public byte[] encrypt(byte[] message)
throws java.security.NoSuchAlgorithmException,
javax.crypto.NoSuchPaddingException,
javax.crypto.BadPaddingException,
javax.crypto.IllegalBlockSizeException,
java.security.InvalidKeyException
- Description copied from class:
ASymmetricKey
- Message encryption.
The method should be implemented in the descending classes, according to
the implementation.
- Specified by:
encrypt
in class ASymmetricKey
- Parameters:
message
- The message to be encrypted.
- Returns:
- The encrypted message.
- Throws:
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
java.security.InvalidKeyException
decrypt
public byte[] decrypt(byte[] message)
throws java.security.NoSuchAlgorithmException,
javax.crypto.NoSuchPaddingException,
javax.crypto.BadPaddingException,
javax.crypto.IllegalBlockSizeException,
java.security.InvalidKeyException
- Description copied from class:
ASymmetricKey
- Message decryption.
The method should be implemented in the descending classes, according to
the implementation.
- Specified by:
decrypt
in class ASymmetricKey
- Parameters:
message
- The message to be decrypted.
- Returns:
- The decrypted message.
- Throws:
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
java.security.InvalidKeyException
main
public static void main(java.lang.String[] args)
(c) 2002-2011, http://smslib.org