Sample code for 30+ languages & platforms
DataFlex

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoCrypt
    Variant vBdEncrypted
    Handle hoBdEncrypted
    Variant vSbPlainText
    Handle hoSbPlainText
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
    If (Not(IsComObjectCreated(hoCrypt))) Begin
        Send CreateComObject of hoCrypt
    End

    Get Create (RefClass(cComChilkatBinData)) To hoBdEncrypted
    If (Not(IsComObjectCreated(hoBdEncrypted))) Begin
        Send CreateComObject of hoBdEncrypted
    End
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbPlainText
    If (Not(IsComObjectCreated(hoSbPlainText))) Begin
        Send CreateComObject of hoSbPlainText
    End

    Get ComAppend Of hoSbPlainText "Text to be encrypted" To iSuccess

    // ...
    // Set the secret key ...
    // Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
    // Set the IV if needed ...
    // ...

    Set ComCharset Of hoCrypt To "utf-8"

    Get pvComObject of hoSbPlainText to vSbPlainText
    Get pvComObject of hoBdEncrypted to vBdEncrypted
    Get ComEncryptSb Of hoCrypt vSbPlainText vBdEncrypted To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoCrypt To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure