UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

14 lines (13 loc) 520 B
/** * Generates a hash of the given text using the specified algorithm. * @param {string} text - The text to hash. * @param {'sha256' | 'md5'} [algorithm='sha256'] - The hashing algorithm to use. * @returns {string} The resulting hash as a hexadecimal string. * @example * // Returns the SHA-256 hash of "Hello, World!" * hash("Hello, World!"); * * // Returns the MD5 hash of "Hello, World!" * hash("Hello, World!", "md5"); */ export declare function hash(text: string, algorithm?: 'sha256' | 'md5'): string;