java.security.NoSuchAlgorithmException: No such algorithm: RSA  
Author Message
Johs32





PostPosted: 2006-9-17 4:56:00 Top

java-programmer, java.security.NoSuchAlgorithmException: No such algorithm: RSA I have this code


import java.io.*;
import java.security.*;
import javax.crypto.*;

class Encrypt {
private Cipher RSAtransform;

public Encrypt()
{

Provider rsajca = new com.sun.rsajca.Provider();
Security.addProvider(rsajca);
try
{
RSAtransform = Cipher.getInstance("RSA",rsajca);
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
catch (NoSuchPaddingException e) {
e.printStackTrace();
}

}
...
...

But when I run it on winxp (using Java 1.4.2) I get:

java.security.NoSuchAlgorithmException: No such algorithm: RSA
at javax.crypto.SunJCE_b.c(DashoA6275)
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.Cipher.a(DashoA6275)
at javax.crypto.Cipher.getInstance(DashoA6275)
at keys.Encrypt.<init>(Encrypt.java:18)
at keys.Encrypt.main(Encrypt.java:115)
java.lang.NullPointerException
at keys.Encrypt.encrypt(Encrypt.java:73)
at keys.Encrypt.main(Encrypt.java:128)




Why is it not possible to use the RSA algorithm?

I would prefer to use an asymmetric algorithm instead of DES.

Hope someone can help

JOhs


 
Johs32





PostPosted: 2006-9-17 6:30:00 Top

java-programmer >> java.security.NoSuchAlgorithmException: No such algorithm: RSA I now use the Bouncy Castle package and it works. The only problem is that
if I encrypt a String then for some reason the decrypted version is missing
the last char. encrypt("bubba") decrypts to "bubb", any idea what might be
causing this?

Johs