Skip to content

fundamentool


hash

Functions

hash()

ts
function hash(text, type?): string;

Defined in: src/node/hash.ts:13

Creates a hex hash of text using Node.js crypto.

Parameters

ParameterTypeDefault valueDescription
textstring | Buffer<ArrayBufferLike>undefinedText or Buffer to hash.
typestring'sha256'Hash algorithm (default: 'sha256').

Returns

string

Hex-encoded hash string.

Example

ts
hash('hello');         // => '2cf24dba...' (sha256)
hash('hello', 'md5');  // => '5d41402a...'

MIT License