Sample code for 30+ languages & platforms
C

Workaround for the deprecated Crypt2.HashFile method

Shows how to replace the deprecated HashFile method. (Chilkat is moving away from the use of CkByteData.)

Chilkat C Downloads

C
#include <C_CkCrypt2.h>
#include <C_CkByteData.h>

void ChilkatSample(void)
    {
    HCkCrypt2 crypt;
    const char *path;
    HCkByteData outData;
    const char *hex_hash;

    crypt = CkCrypt2_Create();

    CkCrypt2_putHashAlgorithm(crypt,"sha256");

    path = "c:/someDir/example.dat";

    //  ------------------------------------------------------------------------
    //  The HashFile method is deprecated:

    outData = CkByteData_Create();
    success = CkCrypt2_HashFile(crypt,path,outData);

    //  ------------------------------------------------------------------------
    //  Workaround.
    //  (Chilkat is moving away from using CkByteData)

    CkCrypt2_putEncodingMode(crypt,"hex_lower");
    hex_hash = CkCrypt2_hashFileENC(crypt,path);


    CkCrypt2_Dispose(crypt);
    CkByteData_Dispose(outData);

    }