Skip to content

getDigestFromRawData

getDigestFromRawData(blob): unknown

Computes a Blake2 H256 hash digest from the provided raw data (blob).

This function verifies if the input blob is serialized before hashing it.

Parameters

blob: string

The raw data input for which the digest needs to be calculated. This should be a serialized string.

Returns

unknown

A promise that resolves to the computed digest of the blob, represented as a hexadecimal string.

Throws

If the blob is not serialized.

Example

const rawData = '{"key": "value"}';
try {
const digest = await getDigestFromRawData(rawData);
console.log(`Computed Digest: ${digest}`);
} catch (error) {
console.error(error.message);
}

Source

registry/src/Registry.ts:82