Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.security.NoSuchAlgorithmException: No such algorithm: RSA

869 views
Skip to first unread message

Johs32

unread,
Sep 16, 2006, 4:55:56 PM9/16/06
to
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

unread,
Sep 16, 2006, 6:29:52 PM9/16/06
to
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


0 new messages