Sample code for 30+ languages & platforms
DataFlex

Use Base64 RSA Key to Encrypt

See more RSA Examples

Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Variant vPubkey
    Handle hoPubkey
    Handle hoRsa
    String sEncryptedStr
    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(cComChilkatPublicKey)) To hoPubkey
    If (Not(IsComObjectCreated(hoPubkey))) Begin
        Send CreateComObject of hoPubkey
    End

    Get ComLoadBase64 Of hoPubkey "MIICdgIBADA ... A9PXLk+j5A==" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoPubkey To sTemp1
        Showln sTemp1
        Procedure_Return
    End

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

    Get pvComObject of hoPubkey to vPubkey
    Get ComUsePublicKey Of hoRsa vPubkey To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoRsa To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Set ComEncodingMode Of hoRsa To "base64"

    Get ComEncryptStringENC Of hoRsa "12345678" False To sEncryptedStr

    Showln sEncryptedStr


End_Procedure