(C++) Workaround for the deprecated Crypt2.HashBytesENC method
Shows how to replace the deprecated HashBytesENC method. (Chilkat is moving away from the use of CkByteData.) Note: This example requires Chilkat v11.0.0 or greater.
#include <CkCrypt2.h>
#include <CkByteData.h>
#include <CkBinData.h>
void ChilkatSample(void)
{
CkCrypt2 crypt;
crypt.put_HashAlgorithm("sha256");
crypt.put_EncodingMode("base64");
const char *path = "c:/someDir/example.dat";
// ------------------------------------------------------------------------
// The HashBytes method is deprecated:
CkByteData inData;
inData.loadFile(path);
const char *base64_hash = crypt.hashBytesENC(inData);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData)
CkBinData bdIn;
bdIn.LoadFile(path);
base64_hash = crypt.hashBdENC(bdIn);
}
|