Hash Generator

Security

Generate hashes with MD5, SHA-1, SHA-256, SHA-384, SHA-512 and HMAC support.

Import

Import
import { hash } from 'toolmetry';

API Reference

FunctionParametersReturnsDescription
hashGenerateinput: string, algorithm?: string, encoding?: stringstringGenerate a hash (Node.js sync)
hashAsyncinput: string, algorithm?: string, encoding?: stringPromise<string>Async hash (browser + Node)
hmacGenerateinput: string, secret: string, algorithm?: stringstringGenerate HMAC hash (Node.js)
hashAllinput: stringRecord<string, string>Generate all algorithm hashes at once

Examples

SHA-256 Hash
import { hashGenerate } from 'toolmetry';

const sha256 = hashGenerate('hello', 'sha256');
// "2cf24dba5fb0a30e26e83b2ac5b9e29e..."
Async Hash (Browser)
import { hashAsync } from 'toolmetry';

const hash = await hashAsync('hello', 'SHA-256');
// Works in both browser and Node.js
All Hashes at Once
import { hashAll } from 'toolmetry';

const all = hashAll('hello');
// { md5: "...", sha1: "...", sha256: "...", sha384: "...", sha512: "..." }
HMAC
import { hmacGenerate } from 'toolmetry';

const hmac = hmacGenerate('message', 'secret-key', 'sha256');
// Node.js only

Try It Live