Sample code for 30+ languages & platforms
PureBasic

Convert DSA Public Key DER to PEM

See more DSA Examples

Converts a DSA public key from DER format to PEM.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkDsa.pb"

Procedure ChilkatExample()

    success.i = 0

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

    dsa.i = CkDsa::ckCreate()
    If dsa.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; Load a DER public key.
    success = CkDsa::ckFromPublicDerFile(dsa,"dsa_pub.der")
    If success <> 1
        Debug CkDsa::ckLastErrorText(dsa)
        CkDsa::ckDispose(dsa)
        ProcedureReturn
    EndIf

    pemStr.s

    ; Save the public key to PEM:
    pemStr = CkDsa::ckToPublicPem(dsa)
    success = CkDsa::ckSaveText(dsa,pemStr,"dsa_pub.pem")
    If success <> 1
        Debug CkDsa::ckLastErrorText(dsa)
        CkDsa::ckDispose(dsa)
        ProcedureReturn
    EndIf

    Debug "Finished!"


    CkDsa::ckDispose(dsa)


    ProcedureReturn
EndProcedure