Class AesBytesEncryptor
- java.lang.Object
- 
- org.springframework.security.crypto.encrypt.AesBytesEncryptor
 
- 
- All Implemented Interfaces:
- BytesEncryptor
 
 public final class AesBytesEncryptor extends java.lang.Object implements BytesEncryptor Encryptor that uses AES encryption.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAesBytesEncryptor.CipherAlgorithm
 - 
Constructor SummaryConstructors Constructor Description AesBytesEncryptor(java.lang.String password, java.lang.CharSequence salt)Constructs an encryptor that uses AES encryption.AesBytesEncryptor(java.lang.String password, java.lang.CharSequence salt, BytesKeyGenerator ivGenerator)Constructs an encryptor that uses AES encryption.AesBytesEncryptor(java.lang.String password, java.lang.CharSequence salt, BytesKeyGenerator ivGenerator, AesBytesEncryptor.CipherAlgorithm alg)Constructs an encryptor that uses AES encryption.AesBytesEncryptor(javax.crypto.SecretKey secretKey, BytesKeyGenerator ivGenerator, AesBytesEncryptor.CipherAlgorithm alg)Constructs an encryptor that uses AES encryption.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decrypt(byte[] encryptedBytes)Decrypt the byte array.byte[]encrypt(byte[] bytes)Encrypt the byte array.
 
- 
- 
- 
Constructor Detail- 
AesBytesEncryptorpublic AesBytesEncryptor(java.lang.String password, java.lang.CharSequence salt)Constructs an encryptor that uses AES encryption. Example:AesBytesEncryptor encryptor = new AesBytesEncryptor(yourPassword, 5c0744940b5c369b);Constructed encryptor uses a 16-byte IV and CBC mode encryption. To specify a custom length IV, useAesBytesEncryptor(String, CharSequence, BytesKeyGenerator). To specify both, a custom length IV and a different encryption mode, useAesBytesEncryptor(String, CharSequence, BytesKeyGenerator, CipherAlgorithm).- Parameters:
- password- the password value
- salt- the hex-encoded salt value
 
 - 
AesBytesEncryptorpublic AesBytesEncryptor(java.lang.String password, java.lang.CharSequence salt, BytesKeyGenerator ivGenerator)Constructs an encryptor that uses AES encryption. Example:AesBytesEncryptor encryptor = new AesBytesEncryptor(yourPassword, 5c0744940b5c369b, KeyGenerators.secureRandom(16));Constructed encryptor uses CBC mode encryption. To specify a different encryption mode, useAesBytesEncryptor(String, CharSequence, BytesKeyGenerator, CipherAlgorithm).- Parameters:
- password- the password value
- salt- the hex-encoded salt value
- ivGenerator- the generator used to generate the initialization vector
 
 - 
AesBytesEncryptorpublic AesBytesEncryptor(java.lang.String password, java.lang.CharSequence salt, BytesKeyGenerator ivGenerator, AesBytesEncryptor.CipherAlgorithm alg)Constructs an encryptor that uses AES encryption. Example:AesBytesEncryptor encryptor = new AesBytesEncryptor(yourPassword, 5c0744940b5c369b, KeyGenerators.secureRandom(16), CipherAlgorithm.GCM);- Parameters:
- password- the password value
- salt- the hex-encoded salt value
- ivGenerator- the generator used to generate the initialization vector
- alg- the- AesBytesEncryptor.CipherAlgorithmto be used
 
 - 
AesBytesEncryptorpublic AesBytesEncryptor(javax.crypto.SecretKey secretKey, BytesKeyGenerator ivGenerator, AesBytesEncryptor.CipherAlgorithm alg)Constructs an encryptor that uses AES encryption.- Parameters:
- secretKey- the secret (symmetric) key
- ivGenerator- the generator used to generate the initialization vector. If null, then a default algorithm will be used based on the provided- AesBytesEncryptor.CipherAlgorithm
- alg- the- AesBytesEncryptor.CipherAlgorithmto be used
 
 
- 
 - 
Method Detail- 
encryptpublic byte[] encrypt(byte[] bytes) Description copied from interface:BytesEncryptorEncrypt the byte array.- Specified by:
- encryptin interface- BytesEncryptor
 
 - 
decryptpublic byte[] decrypt(byte[] encryptedBytes) Description copied from interface:BytesEncryptorDecrypt the byte array.- Specified by:
- decryptin interface- BytesEncryptor
 
 
- 
 
-