java.security.NoSuchAlgorithmException: Cannot find any provider supporting
Hi All
I am using J2SE1.4.2_09 and trying a RSA based encryption and decryption program.
I get the following exception,
java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/ECB/PKCS1Padding
at javax.crypto.Cipher.getInstance(DashoA12275)
at RSAEncrypt.<init>(RSAEncrypt.java:56)
at RSAEncrypt.main(RSAEncrypt.java:96)
The code is
public RSAEncrypt(String inFileName, String outFileName) {
try {
/* Get the secret message from file. */
FileInputStream plainfile = new FileInputStream(inFileName);
byte[] plaintext = new byte[plainfile.available()];
plainfile.read(plaintext);
plainfile.close();
/* Get the public key from file. */
PublicKey publickey = readPublicKey("publickey.txt");
/* Create a cipher for encrypting. */
Cipher encrypt_cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
encrypt_cipher.init(Cipher.ENCRYPT_MODE, publickey);
/* Encrypt the secret message and store in file. */
byte[] ciphertext = encrypt_cipher.doFinal(plaintext);
FileOutputStream cipherfile = new FileOutputStream(outFileName);
cipherfile.write(ciphertext);
cipherfile.close();
} catch (Exception e) {
e.printStackTrace();
}
}
I tried some steps like,
Cipher encrypt_cipher = Cipher.getInstance("RSA");
Still I get the same error.
Please help me.
Regards
Kathirvel

