UNPKG

@kikiutils/node

Version:

A modular utility library for Node.js offering secure hashing, flexible logging, datetime manipulation, and more.

1 lines 1.52 kB
{"version":3,"file":"hash.cjs","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":["bytesToHex","sha3_224","sha3_256","sha3_384","sha3_512"],"mappings":";;;;;AAAA;;;;;;;;;;;AAWG;AAUU,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAKA,gBAAU,CAACC,aAAQ,CAAC,IAAI,CAAC;AAClE,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAKD,gBAAU,CAACE,aAAQ,CAAC,IAAI,CAAC;AAClE,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAKF,gBAAU,CAACG,aAAQ,CAAC,IAAI,CAAC;AAClE,MAAA,OAAO,GAAG,CAAC,IAAyB,KAAKH,gBAAU,CAACI,aAAQ,CAAC,IAAI,CAAC;;;;;;;"}