Computes the SHA-2-256 hash of a value.
sha256(value, outputFormat?)
value
A string, a Uint8Array, a Int8Array, or an ArrayBuffer to hash. If a string, it will be UTF-8 encoded into bytes.
outputFormat optional
The format of the hash digest: "hex" or "bytes". Defaults to "hex".
If "hex", the return value will be a hex string.
If "bytes", the return value will be a Uint8Array.
A hex string or a Uint8Array representing the hash digest.
sha256("hello")
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
sha256("hello", "bytes")
Uint8Array [44, 242, 77, 186, 95, 176, 163, 14, 38, 232, 59, 42, 197, 185, 226, 158, 27, 22, 30, 92, 31, 167, 66, 94, 115, 4, 51, 98, 147, 139, 152, 36]
sha256(new Uint8Array([1,2,3]))
"039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81"