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

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oPkey
LOCAL oPubKey

nSuccess := 0

oPkey := CreateObject("Chilkat.PrivateKey")

//  Load the private key from an PEM file:
nSuccess := oPkey:LoadPemFile("private.pem")
IF (nSuccess == 0)
    ? oPkey:LastErrorText
    oPkey:destroy()
    RETURN
ENDIF

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

nSuccess := oPubKey:SavePemFile(0, "pubKey.pem")
IF (nSuccess != 1)
    ? oPubKey:LastErrorText
    oPubKey:destroy()
    oPkey:destroy()
    oPubKey:destroy()
    RETURN
ENDIF

? "Success."

oPkey:destroy()
oPubKey:destroy()