public class AESEncryption
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
AESEncryption.Settings |
| Constructor and Description |
|---|
AESEncryption() |
AESEncryption(AESEncryption.Settings settings) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] key,
byte[] data)
Decrypt the data with the given key.
|
void |
decrypt(byte[] key,
java.io.InputStream in,
java.io.OutputStream out)
Read and decrypt the data from the input stream and write it to the output stream.
|
byte[] |
encrypt(byte[] key,
byte[] data)
Encrypt the data with the given key.
|
void |
encrypt(byte[] key,
java.io.InputStream in,
java.io.OutputStream out)
Read and encrypt the data from the input stream and write it to the output stream.
|
public AESEncryption()
public AESEncryption(AESEncryption.Settings settings)
public byte[] encrypt(byte[] key,
byte[] data)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidAlgorithmParameterException,
java.security.InvalidKeyException,
java.io.IOException,
javax.crypto.IllegalBlockSizeException,
javax.crypto.BadPaddingException
key - The key to encrypt the datadata - The data to encryptjava.security.NoSuchAlgorithmException - If the algorithm is not supportedjava.security.spec.InvalidKeySpecException - If the key specification is invalidjavax.crypto.NoSuchPaddingException - If the padding is not supportedjava.security.InvalidAlgorithmParameterException - If the algorithm parameters are invalidjava.security.InvalidKeyException - If the key is invalidjava.io.IOException - If an I/O error occursjavax.crypto.IllegalBlockSizeException - If the block size is invalidjavax.crypto.BadPaddingException - If the padding is invalidpublic void encrypt(byte[] key,
@WillNotClose
java.io.InputStream in,
@WillNotClose
java.io.OutputStream out)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidAlgorithmParameterException,
java.security.InvalidKeyException,
java.io.IOException,
javax.crypto.IllegalBlockSizeException,
javax.crypto.BadPaddingException
key - The key to encrypt the datain - The input stream to read the data fromout - The output stream to write the encrypted data tojava.security.NoSuchAlgorithmException - If the algorithm is not supportedjava.security.spec.InvalidKeySpecException - If the key specification is invalidjavax.crypto.NoSuchPaddingException - If the padding is not supportedjava.security.InvalidAlgorithmParameterException - If the algorithm parameters are invalidjava.security.InvalidKeyException - If the key is invalidjava.io.IOException - If an I/O error occursjavax.crypto.IllegalBlockSizeException - If the block size is invalidjavax.crypto.BadPaddingException - If the padding is invalidpublic byte[] decrypt(byte[] key,
byte[] data)
throws java.io.IOException,
java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidAlgorithmParameterException,
java.security.InvalidKeyException,
javax.crypto.IllegalBlockSizeException,
javax.crypto.BadPaddingException
key - The key to decrypt the datadata - The data to decryptjava.io.IOException - If an I/O error occursjava.security.NoSuchAlgorithmException - If the algorithm is not supportedjava.security.spec.InvalidKeySpecException - If the key specification is invalidjavax.crypto.NoSuchPaddingException - If the padding is not supportedjava.security.InvalidAlgorithmParameterException - If the algorithm parameters are invalidjava.security.InvalidKeyException - If the key is invalidjavax.crypto.IllegalBlockSizeException - If the block size is invalidjavax.crypto.BadPaddingException - If the padding is invalidpublic void decrypt(byte[] key,
@WillNotClose
java.io.InputStream in,
@WillNotClose
java.io.OutputStream out)
throws java.io.IOException,
java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidAlgorithmParameterException,
java.security.InvalidKeyException,
javax.crypto.IllegalBlockSizeException,
javax.crypto.BadPaddingException
key - The key to decrypt the datain - The input stream to read the data fromout - The output stream to write the decrypted data tojava.io.IOException - If an I/O error occursjava.security.NoSuchAlgorithmException - If the algorithm is not supportedjava.security.spec.InvalidKeySpecException - If the key specification is invalidjavax.crypto.NoSuchPaddingException - If the padding is not supportedjava.security.InvalidAlgorithmParameterException - If the algorithm parameters are invalidjava.security.InvalidKeyException - If the key is invalidjavax.crypto.IllegalBlockSizeException - If the block size is invalidjavax.crypto.BadPaddingException - If the padding is invalid