sha256Hex
The SHA-256 digest of some data as a hexadecimal string, optionally cut short: a compact content key, not a security check (a short prefix is easy to collide).
Outside a runtime with Web Crypto (crypto.subtle), it rejects with a TypeError.
Available since v3.1.10
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | BufferSource | The data to hash |
length | number | How many hex digits to keep, from `1` to `64`. Defaults to `16` |
Returns
Section titled “Returns”Promise<string> — The first length digits of the digest, in lowercase
Examples
Section titled “Examples”Content key
Section titled “Content key”A short prefix of the digest names a piece of content.
