简体   繁体   中英

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, however 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());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM