Sample code for 30+ languages & platforms
DataFlex

DSA Public Key PEM to DER Conversion

See more DSA Examples

Converts a DSA public key from PEM format to DER.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoDsa
    String sPemPublicKey
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatDsa)) To hoDsa
    If (Not(IsComObjectCreated(hoDsa))) Begin
        Send CreateComObject of hoDsa
    End

    // Load a PEM public key.

    Get ComLoadText Of hoDsa "dsa_pub.pem" To sPemPublicKey
    // Import the public key PEM into the DSA object.
    Get ComFromPublicPem Of hoDsa sPemPublicKey To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoDsa To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Write it out as a DER file:
    Get ComToPublicDerFile Of hoDsa "dsa_pub.der" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoDsa To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Finished!"


End_Procedure