@kikiutils/node
Version:
A modular utility library for Node.js offering secure hashing, flexible logging, datetime manipulation, and more.
1 lines • 1.45 kB
Source Map (JSON)
{"version":3,"file":"hash.mjs","sources":["../src/hash.ts"],"sourcesContent":["/**\n * This file provides a set of functions for creating SHA-3 hash digests using different bit lengths (224, 256, 384, 512).\n * These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.\n * Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.\n *\n * @example\n * ```typescript\n * import { sha3256 } from '@kikiutils/node/hash';\n *\n * console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\n\nimport {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3';\nimport { bytesToHex } from '@noble/hashes/utils';\n\nexport const sha3224 = (data: string | Uint8Array) => bytesToHex(sha3_224(data));\nexport const sha3256 = (data: string | Uint8Array) => bytesToHex(sha3_256(data));\nexport const sha3384 = (data: string | Uint8Array) => bytesToHex(sha3_384(data));\nexport const sha3512 = (data: string | Uint8Array) => bytesToHex(sha3_512(data));\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;AAWG;AAUU,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAK,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClE,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAK,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClE,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAK,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClE,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAK,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;;;;"}