开发者

Cryptography - RSA Algorithm in Java 1.4

I am using Java 1.4.2_10 and I am trying to use RSA encryption:

I am getting the NoSuchAlgorithmException for the following code:

cipher = Cipher.getInstance("RSA");

This is the error:

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA
        at javax.crypto.Cipher.getInstance(DashoA6275)

This works fine in 1.5 and above, ho开发者_Python百科wever I need to use 1.4. Is there any workaround or thirdparty product that I can use to fix this?

Thanks in advance.


You can install the Bouncy Castle cryptography provider. Just grab their jars and then call Cipher.getInstance("RSA", "BC")


Java 1.4 definitely supports RSA, so the fact that this isn't working suggests that something deeper is wrong. Does this work with any other ciphers (such as "AES" or "DES")? You should check to make sure your providers are properly configured. What is the output of the following code on your system:

System.out.println("Providers: ");
java.security.Provider[] providers =  java.security.Security.getProviders();
for(int x = 0; x < providers.length; x++) {
    System.out.println("\t" + providers[x]);
}

System.out.println();
System.out.println("Algorithms: ");
java.util.Set algs = java.security.Security.getAlgorithms("Cipher");

java.util.Iterator i_algs = algs.iterator(); 
while(i_algs.hasNext()) {
    System.out.println("\t" + i_algs.next());
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜