Sample code for 30+ languages & platforms
PowerBuilder

Use Base64 RSA Key to Encrypt

See more RSA Examples

Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Pubkey
oleobject loo_Rsa
string ls_EncryptedStr

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Pubkey = create oleobject
li_rc = loo_Pubkey.ConnectToNewObject("Chilkat.PublicKey")
if li_rc < 0 then
    destroy loo_Pubkey
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_Success = loo_Pubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
if li_Success = 0 then
    Write-Debug loo_Pubkey.LastErrorText
    destroy loo_Pubkey
    return
end if

loo_Rsa = create oleobject
li_rc = loo_Rsa.ConnectToNewObject("Chilkat.Rsa")

li_Success = loo_Rsa.UsePublicKey(loo_Pubkey)
if li_Success = 0 then
    Write-Debug loo_Rsa.LastErrorText
    destroy loo_Pubkey
    destroy loo_Rsa
    return
end if

loo_Rsa.EncodingMode = "base64"

ls_EncryptedStr = loo_Rsa.EncryptStringENC("12345678",0)

Write-Debug ls_EncryptedStr


destroy loo_Pubkey
destroy loo_Rsa