Interface Encryption
- All Known Implementing Classes:
ChaCha20Poly1305Encryption
,DefaultEncryption
,NoOpEncryption
public interface Encryption
Defines a contract for encrypting and decrypting sensitive values within the system.
This interface is commonly used by property sources and serializers to handle secure values, ensuring that sensitive data like passwords, tokens, or credentials are stored and transmitted in encrypted form.
Implementations of this interface are responsible for both the encryption logic and for identifying whether a given value is already encrypted.
Typical usage includes:
- Encrypting properties before persisting or transmitting them
- Decrypting properties during configuration loading or message handling
- Checking if a value needs to be decrypted or should remain untouched
-
Method Summary
Modifier and TypeMethodDescriptionDecrypts the given encrypted value.Encrypts the given plain-text value using the configured encryption algorithm and key.Returns the name or identifier of the encryption algorithm used.Returns the encryption key used by this implementation.boolean
isEncrypted
(String value) Returnstrue
if the given value is considered encrypted by this implementation.
-
Method Details
-
encrypt
Encrypts the given plain-text value using the configured encryption algorithm and key.- Parameters:
value
- the plain-text value to encrypt- Returns:
- the encrypted form of the input value
-
decrypt
Decrypts the given encrypted value.This method assumes that the input is a properly formatted encrypted value produced by the corresponding
encrypt(String)
method.- Parameters:
value
- the encrypted string to decrypt- Returns:
- the decrypted plain-text value
-
getAlgorithm
String getAlgorithm()Returns the name or identifier of the encryption algorithm used.- Returns:
- the name of the algorithm (e.g., "AES", "RSA", "noop")
-
getEncryptionKey
String getEncryptionKey()Returns the encryption key used by this implementation.- Returns:
- the configured key for encryption/decryption, usually a secret or secret reference
-
isEncrypted
Returnstrue
if the given value is considered encrypted by this implementation.Useful for avoiding double-encryption or determining if decryption is required.
- Parameters:
value
- the value to check- Returns:
true
if the value appears to be encrypted,false
otherwise
-