Hi all,

I try to make use of BouncyCastle API. But was unsuccessful
Download the file at http://www.bouncycastle.org/download/crypto-146.zip

I try to add the file but still not successful using below example.

Appreciate anyone can provides me the answer.

Using netbean 7.0 and JDK jdk1.6.0_21

El Gama code
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
package elgama;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
public class ElGama {
  public static void main(String[] args) throws Exception {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    byte[] input = "ab".getBytes();
    Cipher cipher = Cipher.getInstance("ElGamal/None/NoPadding", "BC");
    KeyPairGenerator generator = KeyPairGenerator.getInstance("ElGamal", "BC");
    SecureRandom random = new SecureRandom();
    generator.initialize(128, random);
    KeyPair pair = generator.generateKeyPair();
    Key pubKey = pair.getPublic();
    Key privKey = pair.getPrivate();
    cipher.init(Cipher.ENCRYPT_MODE, pubKey, random);
    byte[] cipherText = cipher.doFinal(input);
    System.out.println("cipher: " + new String(cipherText));
    cipher.init(Cipher.DECRYPT_MODE, privKey);
    byte[] plainText = cipher.doFinal(cipherText);
    System.out.println("plain : " + new String(plainText));

Error code.
Caused by: java.lang.RuntimeException: Uncompilable source code - package org.bouncycastle.jce.provider does not exist
	at elgama.ElGama.<clinit>(ElGama.java:16)
Could not find the main class: elgama.ElGama.  Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)