Sample code for 30+ languages & platforms
DataFlex

Example: Crypt2.EncryptEncoded method

Demonstrates how to call the EncryptEncoded method.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoCrypt
    String sEncrypted
    String sDecrypted

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

    Set ComCryptAlgorithm Of hoCrypt To "aes"
    Set ComCipherMode Of hoCrypt To "cbc"
    Set ComKeyLength Of hoCrypt To 128
    Send ComSetEncodedKey To hoCrypt "000102030405060708090A0B0C0D0E0F" "hex"
    Send ComSetEncodedIV To hoCrypt "000102030405060708090A0B0C0D0E0F" "hex"

    // Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A
    // and return the encrypted bytes using the lowercase hex encoding.
    Set ComEncodingMode Of hoCrypt To "hex_lower"
    Get ComEncryptEncoded Of hoCrypt "000102030405060708090a" To sEncrypted
    Showln sEncrypted

    // Output:
    // 9da2ae71a5378487114b430e5e230378

    Get ComDecryptEncoded Of hoCrypt sEncrypted To sDecrypted
    Showln sDecrypted

    // Output:
    // 000102030405060708090a


End_Procedure