(PowerBuilder) RSA Import Private Key
Shows how to select/import a private key for RSA signing or decryption.Note: This example requires Chilkat v11.0.0 or greater.
integer li_rc
integer li_Success
oleobject loo_PrivKey
string ls_Password
oleobject loo_Rsa
li_Success = 0
loo_PrivKey = create oleobject
li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey")
if li_rc < 0 then
destroy loo_PrivKey
MessageBox("Error","Connecting to COM object failed")
return
end if
ls_Password = "secret"
// In all Chilkat methods expecting a path, you pass either absolute or relative paths.
li_Success = loo_PrivKey.LoadAnyFormatFile("rsaKeys/myTestRsaPrivate.pem",ls_Password)
if li_Success = 0 then
Write-Debug loo_PrivKey.LastErrorText
destroy loo_PrivKey
return
end if
loo_Rsa = create oleobject
li_rc = loo_Rsa.ConnectToNewObject("Chilkat.Rsa")
// Tell the RSA object to use the private key (i.e. import the private key)
loo_Rsa.UsePrivateKey(loo_PrivKey)
destroy loo_PrivKey
destroy loo_Rsa
|