Hi Experts,
While encrypting the input message using public key we are getting the below error exception .
" java.security.NoSuchAlgorithmException: No such algorithm: RSA/ECB/PKCS1Padding" .
Here is the small piece of code we used for encryption .
inKey = PGPUtil.getDecoderStream(inKey); // inKey contains public key info
PGPPublicKeyRingCollection pkCol = new PGPPublicKeyRingCollection(inKey);
Iterator it = pkCol.getKeyRings();
while (it.hasNext()) {pkRing = (PGPPublicKeyRing) it.next();
Iterator pkIt = pkRing.getPublicKeys();
while (pkIt.hasNext()) {
temp = (PGPPublicKey) pkIt.next();
if (temp.isEncryptionKey()) {
pubkey = temp;
break; } }
out = new DataOutputStream(out);
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(PGPCompressedDataGenerator.ZIP);
PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator();
OutputStream pOut = lData.open(comData.open(bOut),PGPLiteralData.BINARY, "", inputString.length(),new Date());
pOut.write(inputString.getBytes());
lData.close();
comData.close();
cPk.close(); out.close();
PGPEncryptedDataGenerator cPk = new PGPEncryptedDataGenerator(PGPEncryptedDataGenerator.CAST5, new SecureRandom(),"BC");
cPk.addMethod(pubkey);
byte[] bytes = bOut.toByteArray();
OutputStream cOut = cPk.open(out, bytes.length); //<-- Here we are getting the above exception
cOut.write(bytes);
cPk.close();
out.close();
Could any one plz guide us ???