Generate hashes with MD5, SHA-1, SHA-256, SHA-384, SHA-512 and HMAC support.
import { hash } from 'toolmetry';| Function | Parameters | Returns | Description |
|---|---|---|---|
hashGenerate | input: string, algorithm?: string, encoding?: string | string | Generate a hash (Node.js sync) |
hashAsync | input: string, algorithm?: string, encoding?: string | Promise<string> | Async hash (browser + Node) |
hmacGenerate | input: string, secret: string, algorithm?: string | string | Generate HMAC hash (Node.js) |
hashAll | input: string | Record<string, string> | Generate all algorithm hashes at once |
import { hashGenerate } from 'toolmetry';
const sha256 = hashGenerate('hello', 'sha256');
// "2cf24dba5fb0a30e26e83b2ac5b9e29e..."import { hashAsync } from 'toolmetry';
const hash = await hashAsync('hello', 'SHA-256');
// Works in both browser and Node.jsimport { hashAll } from 'toolmetry';
const all = hashAll('hello');
// { md5: "...", sha1: "...", sha256: "...", sha384: "...", sha512: "..." }import { hmacGenerate } from 'toolmetry';
const hmac = hmacGenerate('message', 'secret-key', 'sha256');
// Node.js only