|
|
@@ -25,7 +25,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
@Slf4j
|
|
|
public class AsymmetricEncryptionUtil {
|
|
|
|
|
|
- private static final String RSA = "RSA";
|
|
|
+ //private static final String RSA = "RSA";
|
|
|
+ private static final String RSA = "AES/ECB/PKCS7Padding";
|
|
|
private static final ConcurrentHashMap<String,Key> cache = new ConcurrentHashMap<>();
|
|
|
|
|
|
/* public static void main(String[] args) {
|
|
|
@@ -142,7 +143,7 @@ public class AsymmetricEncryptionUtil {
|
|
|
private static String decryptByAsymmetric(String encrypted, Key key) {
|
|
|
try {
|
|
|
// 获取Cipher对象
|
|
|
- Cipher cipher = Cipher.getInstance(RSA);
|
|
|
+ Cipher cipher = Cipher.getInstance(RSA,"CCM");
|
|
|
// 初始化模式(解密)和密钥
|
|
|
cipher.init(Cipher.DECRYPT_MODE, key);
|
|
|
return new String(getMaxResultDecrypt(encrypted, cipher));
|
|
|
@@ -165,7 +166,7 @@ public class AsymmetricEncryptionUtil {
|
|
|
private static String encryptByAsymmetric(String content, Key key) {
|
|
|
try {
|
|
|
// 获取Cipher对象
|
|
|
- Cipher cipher = Cipher.getInstance(RSA);
|
|
|
+ Cipher cipher = Cipher.getInstance(RSA,"CCM");
|
|
|
// 初始化模式(加密)和密钥
|
|
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
|
|
byte[] resultBytes = getMaxResultEncrypt(content, cipher);
|