Sample code for 30+ languages & platforms
Java

RSA Import Public Key

See more RSA Examples

Shows how to select/import a public key for RSA encryption or signature verification.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkPublicKey pubKey = new CkPublicKey();
    //  In all Chilkat methods expecting a path, you pass either absolute or relative paths.
    success = pubKey.LoadFromFile("rsaKeys/myTestRsaPublic.pem");
    if (success == false) {
        System.out.println(pubKey.lastErrorText());
        return;
        }

    CkRsa rsa = new CkRsa();

    //  Tell RSA to use the public key.
    rsa.UsePublicKey(pubKey);
  }
}