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

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oBd
LOCAL oPrivKey
LOCAL oPubKey
LOCAL cPubKeyBase64

nSuccess := 0

//  Load a private key from base64.
oBd := CreateObject("Chilkat.BinData")
nSuccess := oBd:AppendEncoded("MHQCA....n0Q==", "base64")

oPrivKey := CreateObject("Chilkat.PrivateKey")
nSuccess := oPrivKey:LoadAnyFormat(oBd, "")
IF (nSuccess == 0)
    ? oPrivKey:LastErrorText
    oBd:destroy()
    oPrivKey:destroy()
    RETURN
ENDIF

oPubKey := CreateObject("Chilkat.PublicKey")
oPrivKey:ToPublicKey(oPubKey)

cPubKeyBase64 := oPubKey:GetEncoded(1, "base64")
? cPubKeyBase64

oBd:destroy()
oPrivKey:destroy()
oPubKey:destroy()