@kikiutils/node
Version:
A modular utility library for Node.js offering secure hashing, flexible logging, datetime manipulation, and more.
23 lines (20 loc) • 979 B
JavaScript
import { sha3_224, sha3_256, sha3_384, sha3_512 } from '@noble/hashes/sha3';
import { bytesToHex } from '@noble/hashes/utils';
/**
* This file provides a set of functions for creating SHA-3 hash digests using different bit lengths (224, 256, 384, 512).
* These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.
* Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.
*
* @example
* ```typescript
* import { sha3256 } from '@kikiutils/node/hash';
*
* console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
* ```
*/
const sha3224 = (data) => bytesToHex(sha3_224(data));
const sha3256 = (data) => bytesToHex(sha3_256(data));
const sha3384 = (data) => bytesToHex(sha3_384(data));
const sha3512 = (data) => bytesToHex(sha3_512(data));
export { sha3224, sha3256, sha3384, sha3512 };
//# sourceMappingURL=hash.mjs.map