1.0.1 • Published 10 months ago

hash-fns v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

hash-fns

test publish

easily create, assess, and assure hashes within a pit-of-success

install

npm install hash-fns

use

for example

import { Hash, toHashSha256, isHashSha256 } from 'hash-fns';

// create a hash
const versionHash: Hash = await toHashSha256('some data');

// verify that a given value is a valid hash
const foundHash: Hash = isHashSha256.assure('__hash__');

// typeguard against random strings being passed as hashes
const expectHash: Hash = 'some string'; // 🛑 typescript will throw an error, since string is not assignable to Hash

// use a hash within functions that expect strings
const expectWords: string = await toHashSha256('some data'); // ✅ passes, as Hash is assignable to strings