Skip to content

hashToUri

hashToUri(digest, iDPrefix, prefix): string

Converts a digest to a URI using a specified identifier prefix and a predefined prefix string.

Parameters

digest: any

The input digest to be encoded.

iDPrefix: number

The identifier prefix, used to classify the type of data being encoded.

prefix: string

A predefined string prefix to be appended before the encoded identifier.

Returns

string

A string representing the URI constructed from the digest and identifier prefix.

Example

const digest = '0x1234...';
const uri = hashToUri(digest, 29, 'example:');
console.log('URI:', uri);

Throws

Assert error if the digest is invalid.

Source

identifier/src/Identifier.ts:285