(Tcl) Workaround for the deprecated Crypt2.MacBytesENC method
Shows how to replace the deprecated MacBytesENC method. (Chilkat is moving away from the use of CkByteData.) Note: This example requires Chilkat v11.0.0 or greater.
load ./chilkat.dll
set crypt [new_CkCrypt2]
# Do HMAC using SHA-256.
CkCrypt2_put_MacAlgorithm $crypt "hmac"
CkCrypt2_put_HashAlgorithm $crypt "sha256"
set keyHex "000102030405060708090A0B0C0D0E0F"
set success [CkCrypt2_SetMacKeyEncoded $crypt $keyHex "hex"]
# Return the HMAC using the lowercase hex encoding.
CkCrypt2_put_EncodingMode $crypt "hex_lower"
set path "c:/someDir/example.dat"
# ------------------------------------------------------------------------
# The MacBytesENC method is deprecated:
set inData [new_CkByteData]
CkByteData_loadFile $inData $path
set hmac_hex [CkCrypt2_macBytesENC $crypt $inData]
puts "$hmac_hex"
# ------------------------------------------------------------------------
# Workaround.
# (Chilkat is moving away from using CkByteData)
set bdIn [new_CkBinData]
CkBinData_LoadFile $bdIn $path
set hmac_hex [CkCrypt2_macBdENC $crypt $bdIn]
puts "$hmac_hex"
delete_CkCrypt2 $crypt
delete_CkByteData $inData
delete_CkBinData $bdIn
|