Sample code for 30+ languages & platforms
DataFlex

RSA Import Private Key

See more RSA Examples

Shows how to select/import a private key for RSA signing or decryption.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Variant vPrivKey
    Handle hoPrivKey
    String sPassword
    Handle hoRsa
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey
    If (Not(IsComObjectCreated(hoPrivKey))) Begin
        Send CreateComObject of hoPrivKey
    End
    Move "secret" To sPassword
    // In all Chilkat methods expecting a path, you pass either absolute or relative paths.
    Get ComLoadAnyFormatFile Of hoPrivKey "rsaKeys/myTestRsaPrivate.pem" sPassword To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoPrivKey To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatRsa)) To hoRsa
    If (Not(IsComObjectCreated(hoRsa))) Begin
        Send CreateComObject of hoRsa
    End

    // Tell the RSA object to use the private key (i.e. import the private key)
    Get pvComObject of hoPrivKey to vPrivKey
    Get ComUsePrivateKey Of hoRsa vPrivKey To iSuccess


End_Procedure