@kikiutils/node
Version:
A modular utility library for Node.js offering secure hashing, flexible logging, datetime manipulation, and more.
28 lines (24 loc) • 1.06 kB
JavaScript
;
const sha3 = require('@noble/hashes/sha3');
const utils = require('@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) => utils.bytesToHex(sha3.sha3_224(data));
const sha3256 = (data) => utils.bytesToHex(sha3.sha3_256(data));
const sha3384 = (data) => utils.bytesToHex(sha3.sha3_384(data));
const sha3512 = (data) => utils.bytesToHex(sha3.sha3_512(data));
exports.sha3224 = sha3224;
exports.sha3256 = sha3256;
exports.sha3384 = sha3384;
exports.sha3512 = sha3512;
//# sourceMappingURL=hash.cjs.map