Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

RSA Import Private Key

See more RSA Examples

Shows how to select/import a private key for RSA signing or decryption.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
privKey: HCkPrivateKey;
password: PWideChar;
rsa: HCkRsa;

begin
success := False;

privKey := CkPrivateKey_Create();
password := 'secret';
//  In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success := CkPrivateKey_LoadAnyFormatFile(privKey,'rsaKeys/myTestRsaPrivate.pem',password);
if (success = False) then
  begin
    Memo1.Lines.Add(CkPrivateKey__lastErrorText(privKey));
    Exit;
  end;

rsa := CkRsa_Create();

//  Tell the RSA object to use the private key (i.e. import the private key)
CkRsa_UsePrivateKey(rsa,privKey);

CkPrivateKey_Dispose(privKey);
CkRsa_Dispose(rsa);