Skip to content

qie.getSHA256Hash

Signature: qie.getSHA256Hash(value, base64Encode*)

Returns: String sha256Hash - the SHA256 hash

Returns the SHA256 hash calculated from the specified value.

Parameters

Type Name Description Default
String or byte[] value the value to calculate the SHA256 hash from
Boolean base64Encode* (optional) set to true to Base64 encode the hash value, otherwise the hash will be hex encoded false

Example

// Example: value as String, hex output (default)
var sha256CalculatedHash = qie.getSHA256Hash(
   "This will be turned into a SHA256 hash"
);


// Example: value as byte[], hex output (default)
var inputBytes = [
   84,104,105,115,32,119,105,108,108,32,98,101,32,116,117,114,110,101,100,32,
   105,110,116,111,32,97,32,83,72,65,50,53,54,32,104,97,115,104
]; // "This will be turned into a SHA256 hash"
var sha256HashFromBytes = qie.getSHA256Hash(inputBytes);


// Example: value as String, Base64 output
var sha256HashBase64 = qie.getSHA256Hash(
   "This will be turned into a SHA256 hash",
   true
);