Class AESEncryptionUtils
java.lang.Object
io.getlime.security.powerauth.crypto.lib.util.AESEncryptionUtils
A utility class for AES encryption.
- Author:
- Petr Dvorak
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Decrypt given data using AES/CBC/PKCS7Padding with given initialization vector and secret key.byte[]Decrypt given data using given transformation with given initialization vector and secret key.byte[]Encrypt given data using AES/CBC/PKCS7Padding with given initialization vector and secret key.byte[]Encrypt given data using given transformation with given initialization vector and secret key.
-
Constructor Details
-
AESEncryptionUtils
public AESEncryptionUtils()
-
-
Method Details
-
encrypt
public byte[] encrypt(byte[] bytes, byte[] iv, SecretKey secret, String transformation) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Encrypt given data using given transformation with given initialization vector and secret key.- Parameters:
bytes- Bytes to be encrypted.iv- Initialization vector.secret- Secret signature key.transformation- Cipher transformation to be used, for example "AES/CBC/PKCS7Padding".- Returns:
- Encrypted bytes.
- Throws:
InvalidKeyException- In case an invalid key is provided.GenericCryptoException- In case encryption fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
encrypt
public byte[] encrypt(byte[] bytes, byte[] iv, SecretKey secret) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Encrypt given data using AES/CBC/PKCS7Padding with given initialization vector and secret key.- Parameters:
bytes- Bytes to be encrypted.iv- Initialization vector.secret- Secret signature key.- Returns:
- Encrypted bytes.
- Throws:
InvalidKeyException- In case an invalid key is provided.GenericCryptoException- In case encryption fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
decrypt
public byte[] decrypt(byte[] bytes, byte[] iv, SecretKey secret, String transformation) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Decrypt given data using given transformation with given initialization vector and secret key.- Parameters:
bytes- Encrypted bytes to be decrypted.iv- Initialization vector.secret- Secret signature key.transformation- Cipher transformation to be used, for example "AES/CBC/PKCS7Padding".- Returns:
- Original decrypted bytes.
- Throws:
InvalidKeyException- In case an invalid key is provided.GenericCryptoException- In case decryption fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-
decrypt
public byte[] decrypt(byte[] bytes, byte[] iv, SecretKey secret) throws InvalidKeyException, GenericCryptoException, CryptoProviderException Decrypt given data using AES/CBC/PKCS7Padding with given initialization vector and secret key.- Parameters:
bytes- Encrypted bytes to be decrypted.iv- Initialization vector.secret- Secret signature key.- Returns:
- Original decrypted bytes.
- Throws:
InvalidKeyException- In case an invalid key is provided.GenericCryptoException- In case decryption fails.CryptoProviderException- In case cryptography provider is incorrectly initialized.
-