PowerBuilder
PowerBuilder
Load a Public Key from BinData
Demonstrates the Chilkat PublicKey.LoadBd method, which loads a public key from the bytes in a BinData. The only argument is the BinData, which may contain binary DER or any textual representation recognized by LoadFromString.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: When key bytes are already in memory — downloaded, extracted from a container, or pulled from a database — this loads them directly with no temporary file. It applies the same content inspection as the string and file loaders, so it accepts both binary DER and any recognized text form. It is the in-memory counterpart to
LoadFromFile.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Bd
oleobject loo_PubKey
li_Success = 0
// Demonstrates the PublicKey.LoadBd method, which loads a public key from the bytes in a BinData.
// The only argument is the BinData, which may contain binary DER or any textual representation
// recognized by LoadFromString.
loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")
if li_rc < 0 then
destroy loo_Bd
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Bd.LoadFile("qa_data/public.der")
if li_Success = 0 then
Write-Debug loo_Bd.LastErrorText
destroy loo_Bd
return
end if
loo_PubKey = create oleobject
li_rc = loo_PubKey.ConnectToNewObject("Chilkat.PublicKey")
li_Success = loo_PubKey.LoadBd(loo_Bd)
if li_Success = 0 then
Write-Debug loo_PubKey.LastErrorText
destroy loo_Bd
destroy loo_PubKey
return
end if
Write-Debug "Loaded a " + loo_PubKey.KeyType + " public key."
destroy loo_Bd
destroy loo_PubKey