Sample code for 30+ languages & platforms
Lianja

Get Base64 Public Key from Private Key

See more ECC Examples

Demonstrates how to get the public key in base64 format from a private key.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

// Load a private key from base64.
loBd = createobject("CkBinData")
llSuccess = loBd.AppendEncoded("MHQCA....n0Q==","base64")

loPrivKey = createobject("CkPrivateKey")
llSuccess = loPrivKey.LoadAnyFormat(loBd,"")
if (llSuccess = .F.) then
    ? loPrivKey.LastErrorText
    release loBd
    release loPrivKey
    return
endif

loPubKey = createobject("CkPublicKey")
loPrivKey.ToPublicKey(loPubKey)

lcPubKeyBase64 = loPubKey.GetEncoded(.T.,"base64")
? lcPubKeyBase64


release loBd
release loPrivKey
release loPubKey