Interface ResultEncryptor
- All Known Implementing Classes:
AbstractResultEncryptor, AesResultEncryptor
public interface ResultEncryptor
Result Encryptor SPI
响应加密器SPI
Service Provider Interface for encrypting result data.
加密响应数据的服务提供者接口。
Features | 主要功能:
- Result encryption and decryption - 响应加密和解密
- Algorithm-based dispatch - 基于算法的分发
- Pluggable encryption implementations - 可插拔的加密实现
Usage Examples | 使用示例:
// Encrypt a result
ResultEncryptor encryptor = new AesResultEncryptor(key);
EncryptedResult encrypted = encryptor.encrypt(result);
// Decrypt back
Result<String> decrypted = encryptor.decrypt(encrypted, String.class);
Security | 安全性:
- Thread-safe: Implementation-dependent - 线程安全: 取决于实现
- Null-safe: No (result and encrypted data must not be null) - 空值安全: 否(结果和加密数据不能为 null)
- Since:
- JDK 25, opencode-base-web V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> Result<T> decrypt(EncryptedResult encrypted, TypeReference<T> typeReference) Decrypt to result with generic type support 解密为带泛型类型的响应<T> Result<T> decrypt(EncryptedResult encrypted, Class<T> dataType) Decrypt to result 解密为响应<T> EncryptedResultEncrypt result 加密响应Get the algorithm name 获取算法名称default booleanCheck if this encryptor supports the algorithm 检查此加密器是否支持该算法
-
Method Details
-
encrypt
Encrypt result 加密响应- Type Parameters:
T- the data type | 数据类型- Parameters:
result- the result to encrypt | 要加密的响应- Returns:
- the encrypted result | 加密后的响应
-
decrypt
Decrypt to result 解密为响应- Type Parameters:
T- the data type | 数据类型- Parameters:
encrypted- the encrypted result | 加密的响应dataType- the data type class | 数据类型类- Returns:
- the decrypted result | 解密后的响应
-
getAlgorithm
-
decrypt
Decrypt to result with generic type support 解密为带泛型类型的响应- Type Parameters:
T- the data type | 数据类型- Parameters:
encrypted- the encrypted result | 加密的响应typeReference- the type reference for generic types | 泛型类型引用- Returns:
- the decrypted result | 解密后的响应
-
supports
Check if this encryptor supports the algorithm 检查此加密器是否支持该算法- Parameters:
algorithm- the algorithm to check | 要检查的算法- Returns:
- true if supported | 如果支持返回true
-