我正在使用 cipher java 进行密码解密逻辑。在那,同时使用cipher.getInstance("RSA/NONE/NoPadding")
. 我收到以下异常:NoSuchAlgorithm
.
相同的代码在我的本地 jboss 服务器设置中有效,但在 IBM-WAS 服务器设置中无效。本地 jboss 服务器和 WAS 服务器有什么区别吗?
public static String decrypt(String encrypted, KeyPair keys) {
Cipher dec;
try {
dec = Cipher.getInstance("RSA/NONE/NoPadding"); //Exception raised
dec.init(Cipher.DECRYPT_MODE, keys.getPrivate());
} catch (GeneralSecurityException e) {
throw new RuntimeException("RSA algorithm not supported", e);//Catch block executed
}
}
日志:
R Caused by: java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/NoPadding
at java.lang.Throwable.<init>(Throwable.java:80)
at javax.crypto.Cipher.getInstance(Unknown Source)
at com.lsi.utils.JCryptionUtil.decrypt(JCryptionUtil.java:59)
Caused by: java.security.NoSuchAlgorithmException: Mode: NONE not implemented
at com.ibm.crypto.provider.RSA.engineSetMode(Unknown Source)
at javax.crypto.Cipher$a_.a(Unknown Source)
**Jar**
Jce.jar - javax.crypto.Cipher;
bcprov-jdk15-140.jar (External security provider jar)