(Java) RSA Import Private Key
Shows how to select/import a private key for RSA signing or decryption.
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[])
{
CkPrivateKey privKey = new CkPrivateKey();
String password = "secret";
// In all Chilkat methods expecting a path, you pass either absolute or relative paths.
boolean success = privKey.LoadAnyFormatFile("rsaKeys/myTestRsaPrivate.pem",password);
if (success == false) {
System.out.println(privKey.lastErrorText());
return;
}
CkRsa rsa = new CkRsa();
// Tell the RSA object to use the private key (i.e. import the private key)
rsa.ImportPrivateKeyObj(privKey);
}
}
|