Sample code for 30+ languages & platforms
Unicode C

Example: Crypt2.HashStringENC method

Demonstrates how to call the HashStringENC method.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkCrypt2W.h>

void ChilkatSample(void)
    {
    HCkCrypt2W crypt;
    const wchar_t *s;
    const wchar_t *hashStr;

    crypt = CkCrypt2W_Create();

    s = L"får";

    //  The string "får" in utf-8 is composed of these bytes: 0x66 0xC3 0xA5 0x72
    CkCrypt2W_putCharset(crypt,L"utf-8");

    CkCrypt2W_putEncodingMode(crypt,L"hex_lower");
    CkCrypt2W_putHashAlgorithm(crypt,L"sha256");

    //  Get the hex string for the sha-256 hash of the utf-8 byte representation of the string
    hashStr = CkCrypt2W_hashStringENC(crypt,s);

    wprintf(L"%s\n",hashStr);

    //  Output:
    //  cb8f773dd592337ed7f928012a60f48e1efb357beeda124a54461410e216fece


    CkCrypt2W_Dispose(crypt);

    }