How to solve the NoSuchAlgorithmException in java?

牧云@^-^@ 提交于 2019-12-25 07:00:08

问题


I am trying to decrypt the data using RSA Algorithm. While doing the decryption, I am getting an exception.That is,

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/ECB/PKCS5Padding
        at javax.crypto.Cipher.getInstance(DashoA13*..)

How to solve this exception? Currently, I am using java version "1.6.0_26".


回答1:


It's a typo. The correct name for RSA with PKCS #1 v1.5 padding is "RSA/ECB/PKCS1Padding". Generally, it is a good idea to compare with a list of available algorithms. E.g. this question contains some ways to print such a list.

(And of course using OAEP instead of v1.5 padding would be preferable, especially if your main field is not cryptography).




回答2:


The error means that the library you use cna't decrypt the data because there isn't an algorithm in the Lib which decrypts RSA. You can use a library like Bouncy Calste or GNU Crypto to decrypt data using RSA. There are plenty of samples how to do this on the web.



来源:https://stackoverflow.com/questions/12577185/how-to-solve-the-nosuchalgorithmexception-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!