Sample code for 30+ languages & platforms
DataFlex

Example: Crypt2.HashStringENC method

Demonstrates how to call the HashStringENC method.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoCrypt
    String s
    String sHashStr

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

    Move "får" To s

    // The string "får" in utf-8 is composed of these bytes: 0x66 0xC3 0xA5 0x72
    Set ComCharset Of hoCrypt To "utf-8"

    Set ComEncodingMode Of hoCrypt To "hex_lower"
    Set ComHashAlgorithm Of hoCrypt To "sha256"

    // Get the hex string for the sha-256 hash of the utf-8 byte representation of the string
    Get ComHashStringENC Of hoCrypt s To sHashStr

    Showln sHashStr

    // Output:
    // cb8f773dd592337ed7f928012a60f48e1efb357beeda124a54461410e216fece


End_Procedure