JavaScript
JavaScript
Example: Crypt2.HashStringENC method
Demonstrates how to call the HashStringENC method.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var crypt = new CkCrypt2();
var s = "får";
// The string "får" in utf-8 is composed of these bytes: 0x66 0xC3 0xA5 0x72
crypt.Charset = "utf-8";
crypt.EncodingMode = "hex_lower";
crypt.HashAlgorithm = "sha256";
// Get the hex string for the sha-256 hash of the utf-8 byte representation of the string
var hashStr = crypt.HashStringENC(s);
console.log(hashStr);
// Output:
// cb8f773dd592337ed7f928012a60f48e1efb357beeda124a54461410e216fece