Package com.axelor.common.crypto
Class StringEncryptorPbkdf2Sha512
java.lang.Object
com.axelor.common.crypto.StringEncryptorPbkdf2Sha512
AES encryptor operating on
String values using PBKDF2WithHmacSHA512 key derivation.
Encrypts and decrypts strings by delegating to a BytesEncryptorPbkdf2Sha512 and
encoding the resulting bytes as Base64. The encrypted output starts with the Base64 encoding of
$AESv2$, which is used by Encryptor.isEncrypted(String) to identify ciphertext.
Use the factory methods to select the AES operation mode:
gcm(String)— AES/GCM/NoPadding (recommended: provides authenticated encryption)cbc(String)— AES/CBC/PKCS5Padding
The default constructor uses GCM.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a string encryptor backed by the given bytes encryptor.StringEncryptorPbkdf2Sha512(OperationMode mode, String password) Creates an encryptor for the given mode and password.StringEncryptorPbkdf2Sha512(OperationMode mode, String password, int iterations) Creates an encryptor for the given mode, password, and iteration count.StringEncryptorPbkdf2Sha512(OperationMode mode, String password, int iterations, int saltSize) Creates an encryptor with a custom salt size.StringEncryptorPbkdf2Sha512(String password) Creates a GCM encryptor with the given password. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncryptorPbkdf2Sha512Creates a CBC encryptor with the given password.Decrypt the given encrypted message.Encrypt the given message.static StringEncryptorPbkdf2Sha512Creates a GCM encryptor with the given password.booleanisEncrypted(String message) Check whether the given message is already encrypted or not.toString()
-
Constructor Details
-
StringEncryptorPbkdf2Sha512
Creates a GCM encryptor with the given password. -
StringEncryptorPbkdf2Sha512
Creates an encryptor for the given mode and password.- Parameters:
mode- the AES operation mode (GCM or CBC)password- the password used for PBKDF2 key derivation
-
StringEncryptorPbkdf2Sha512
Creates an encryptor for the given mode, password, and iteration count.- Parameters:
mode- the AES operation mode (GCM or CBC)password- the password used for PBKDF2 key derivationiterations- the PBKDF2 iteration count
-
StringEncryptorPbkdf2Sha512
public StringEncryptorPbkdf2Sha512(OperationMode mode, String password, int iterations, int saltSize) Creates an encryptor with a custom salt size.- Parameters:
mode- the AES operation mode (GCM or CBC)password- the password used for PBKDF2 key derivationiterations- the PBKDF2 iteration countsaltSize- the salt length in bytes
-
StringEncryptorPbkdf2Sha512
Creates a string encryptor backed by the given bytes encryptor.- Parameters:
encryptor- the underlyingBytesEncryptorPbkdf2Sha512
-
-
Method Details
-
gcm
Creates a GCM encryptor with the given password. -
cbc
Creates a CBC encryptor with the given password. -
isEncrypted
Description copied from interface:EncryptorCheck whether the given message is already encrypted or not.- Specified by:
isEncryptedin interfaceEncryptor<String,String> - Parameters:
message- the message to check- Returns:
- true if encrypted
-
encrypt
Description copied from interface:EncryptorEncrypt the given message. -
decrypt
Description copied from interface:EncryptorDecrypt the given encrypted message. -
toString
-