(Java) RSA Import Public Key
Shows how to select/import a public key for RSA encryption or signature verification.Note: This example requires Chilkat v11.0.0 or greater.
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);
}
}
|