Sample code for 30+ languages & platforms
C++

Workaround for the deprecated Crypt2.HashString method

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

Chilkat C++ Downloads

C++
#include <CkCrypt2.h>
#include <CkByteData.h>

void ChilkatSample(void)
    {
    CkCrypt2 crypt;

    crypt.put_Charset("utf-8");

    crypt.put_HashAlgorithm("sha256");

    const char *inputStr = "This is a test.";

    //  ------------------------------------------------------------------------
    //  The HashString method is deprecated:

    CkByteData outData;

    success = crypt.HashString(inputStr,outData);

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

    crypt.put_EncodingMode("base64");
    const char *hash_base64 = crypt.hashStringENC(inputStr);

    std::cout << hash_base64 << "\r\n";
    }