spi 添加秘钥加解密支持

This commit is contained in:
hujun3 2022-03-25 10:25:24 +08:00
parent 88fb26cfc6
commit f1484e9f22
2 changed files with 18 additions and 3 deletions

View File

@ -61,7 +61,7 @@ public class EncryptionHandler {
EncryptionPluginService encryptionPluginService = optional.get(); EncryptionPluginService encryptionPluginService = optional.get();
String secretKey = encryptionPluginService.generateSecretKey(); String secretKey = encryptionPluginService.generateSecretKey();
String encrypt = encryptionPluginService.encrypt(secretKey, content); String encrypt = encryptionPluginService.encrypt(secretKey, content);
return Pair.with(secretKey, encrypt); return Pair.with(secretKey, encryptionPluginService.encryptSecretKey(encrypt));
} }
/** /**
@ -84,8 +84,9 @@ public class EncryptionHandler {
return Pair.with("", content); return Pair.with("", content);
} }
EncryptionPluginService encryptionPluginService = optional.get(); EncryptionPluginService encryptionPluginService = optional.get();
String decrypt = encryptionPluginService.decrypt(secretKey, content); String decryptSecretKey = encryptionPluginService.decryptSecretKey(secretKey);
return Pair.with(secretKey, decrypt); String decryptContent = encryptionPluginService.decrypt(decryptSecretKey, content);
return Pair.with(decryptSecretKey, decryptContent);
} }
/** /**

View File

@ -54,4 +54,18 @@ public interface EncryptionPluginService {
* @return name * @return name
*/ */
String algorithmName(); String algorithmName();
/**
* encrypt secretKey.
* @param secretKey secretKey
* @return encrypted secretKey
*/
String encryptSecretKey(String secretKey);
/**
* decrypt secretKey.
* @param secretKey secretKey
* @return decrypted secretKey
*/
String decryptSecretKey(String secretKey);
} }