@dfinity/utils
Version:
A collection of utilities and constants for NNS/SNS projects.
22 lines (21 loc) • 888 B
TypeScript
/**
* Generates a SHA-256 hash from the given object.
*
* The object is first stringified using a custom `jsonReplacer`, then
* hashed using the SubtleCrypto API. The resulting hash is returned as a hex string.
*
* @template T - The type of the input object.
* @param {T} params - The object to hash.
* @returns {Promise<string>} A promise that resolves to the hex string of the SHA-256 hash.
*/
export declare const hashObject: <T extends object>(params: T) => Promise<string>;
/**
* Generates a SHA-256 hash from a plain text string.
*
* The string is UTF-8 encoded and hashed using the SubtleCrypto API.
* The resulting hash is returned as a hexadecimal string.
*
* @param {string} text - The text to hash.
* @returns {Promise<string>} A promise that resolves to the hex string of the SHA-256 hash.
*/
export declare const hashText: (text: string) => Promise<string>;