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();
String secretKey = encryptionPluginService.generateSecretKey();
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);
}
EncryptionPluginService encryptionPluginService = optional.get();
String decrypt = encryptionPluginService.decrypt(secretKey, content);
return Pair.with(secretKey, decrypt);
String decryptSecretKey = encryptionPluginService.decryptSecretKey(secretKey);
String decryptContent = encryptionPluginService.decrypt(decryptSecretKey, content);
return Pair.with(decryptSecretKey, decryptContent);
}
/**

View File

@ -54,4 +54,18 @@ public interface EncryptionPluginService {
* @return name
*/
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);
}