/
opt
/
canhelp
/
node_modules
/
@noble
/
hashes
/
/opt/canhelp/node_modules/@noble/hashes
mkdir
upload
Name
Size
Mode
Actions
src/
-
0755
rm
argon2.d.ts
1498
0644
edit
dl
rm
argon2.d.ts.map
1137
0644
edit
dl
rm
argon2.js
16308
0644
edit
dl
rm
argon2.js.map
21113
0644
edit
dl
rm
blake1.d.ts
3624
0644
edit
dl
rm
blake1.d.ts.map
3743
0644
edit
dl
rm
blake1.js
19433
0644
edit
dl
rm
blake1.js.map
28454
0644
edit
dl
rm
blake2.d.ts
3907
0644
edit
dl
rm
blake2.d.ts.map
4103
0644
edit
dl
rm
blake2.js
16895
0644
edit
dl
rm
blake2.js.map
25543
0644
edit
dl
rm
blake3.d.ts
1837
0644
edit
dl
rm
blake3.d.ts.map
1296
0644
edit
dl
rm
blake3.js
9627
0644
edit
dl
rm
blake3.js.map
10753
0644
edit
dl
rm
eskdf.d.ts
1752
0644
edit
dl
rm
eskdf.d.ts.map
902
0644
edit
dl
rm
eskdf.js
6550
0644
edit
dl
rm
eskdf.js.map
6007
0644
edit
dl
rm
hkdf.d.ts
1996
0644
edit
dl
rm
hkdf.d.ts.map
553
0644
edit
dl
rm
hkdf.js
3538
0644
edit
dl
rm
hkdf.js.map
2147
0644
edit
dl
rm
hmac.d.ts
1090
0644
edit
dl
rm
hmac.d.ts.map
934
0644
edit
dl
rm
hmac.js
2992
0644
edit
dl
rm
hmac.js.map
3067
0644
edit
dl
rm
index.d.ts
46
0644
edit
dl
rm
index.d.ts.map
101
0644
edit
dl
rm
index.js
1162
0644
edit
dl
rm
index.js.map
180
0644
edit
dl
rm
legacy.d.ts
2579
0644
edit
dl
rm
legacy.d.ts.map
1888
0644
edit
dl
rm
legacy.js
9763
0644
edit
dl
rm
legacy.js.map
13498
0644
edit
dl
rm
LICENSE
1109
0644
edit
dl
rm
package.json
2799
0644
edit
dl
rm
pbkdf2.d.ts
1194
0644
edit
dl
rm
pbkdf2.d.ts.map
576
0644
edit
dl
rm
pbkdf2.js
3898
0644
edit
dl
rm
pbkdf2.js.map
4050
0644
edit
dl
rm
README.md
24015
0644
edit
dl
rm
scrypt.d.ts
1337
0644
edit
dl
rm
scrypt.d.ts.map
658
0644
edit
dl
rm
scrypt.js
9720
0644
edit
dl
rm
scrypt.js.map
12136
0644
edit
dl
rm
sha2.d.ts
6512
0644
edit
dl
rm
sha2.d.ts.map
6359
0644
edit
dl
rm
sha2.js
16773
0644
edit
dl
rm
sha2.js.map
20062
0644
edit
dl
rm
sha3-addons.d.ts
6232
0644
edit
dl
rm
sha3-addons.d.ts.map
4419
0644
edit
dl
rm
sha3-addons.js
17028
0644
edit
dl
rm
sha3-addons.js.map
17483
0644
edit
dl
rm
sha3.d.ts
2325
0644
edit
dl
rm
sha3.d.ts.map
1933
0644
edit
dl
rm
sha3.js
9199
0644
edit
dl
rm
sha3.js.map
10690
0644
edit
dl
rm
utils.d.ts
6128
0644
edit
dl
rm
utils.d.ts.map
4117
0644
edit
dl
rm
utils.js
9356
0644
edit
dl
rm
utils.js.map
9127
0644
edit
dl
rm
webcrypto.d.ts
2718
0644
edit
dl
rm
webcrypto.d.ts.map
1099
0644
edit
dl
rm
webcrypto.js
5090
0644
edit
dl
rm
webcrypto.js.map
3969
0644
edit
dl
rm
_blake.d.ts
474
0644
edit
dl
rm
_blake.d.ts.map
553
0644
edit
dl
rm
_blake.js
1661
0644
edit
dl
rm
_blake.js.map
3628
0644
edit
dl
rm
_md.d.ts
1968
0644
edit
dl
rm
_md.d.ts.map
1518
0644
edit
dl
rm
_md.js
5615
0644
edit
dl
rm
_md.js.map
5065
0644
edit
dl
rm
_u64.d.ts
3129
0644
edit
dl
rm
_u64.d.ts.map
4314
0644
edit
dl
rm
_u64.js
3081
0644
edit
dl
rm
_u64.js.map
5045
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/@noble/hashes/utils.js
(9356B)
/** * Utilities for hex, bytes, CSPRNG. * @module */ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */ export function isBytes(a) { return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); } /** Asserts something is positive integer. */ export function anumber(n, title = '') { if (!Number.isSafeInteger(n) || n < 0) { const prefix = title && `"${title}" `; throw new Error(`${prefix}expected integer >= 0, got ${n}`); } } /** Asserts something is Uint8Array. */ export function abytes(value, length, title = '') { const bytes = isBytes(value); const len = value?.length; const needsLen = length !== undefined; if (!bytes || (needsLen && len !== length)) { const prefix = title && `"${title}" `; const ofLen = needsLen ? ` of length ${length}` : ''; const got = bytes ? `length=${len}` : `type=${typeof value}`; throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got); } return value; } /** Asserts something is hash */ export function ahash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash must wrapped by utils.createHasher'); anumber(h.outputLen); anumber(h.blockLen); } /** Asserts a hash instance has not been destroyed / finished */ export function aexists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } /** Asserts output is properly-sized byte array */ export function aoutput(out, instance) { abytes(out, undefined, 'digestInto() output'); const min = instance.outputLen; if (out.length < min) { throw new Error('"digestInto() output" expected to be of length >=' + min); } } /** Cast u8 / u16 / u32 to u8. */ export function u8(arr) { return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); } /** Cast u8 / u16 / u32 to u32. */ export function u32(arr) { return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); } /** Zeroize a byte array. Warning: JS provides no guarantees. */ export function clean(...arrays) { for (let i = 0; i < arrays.length; i++) { arrays[i].fill(0); } } /** Create DataView of an array for easy byte-level manipulation. */ export function createView(arr) { return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); } /** The rotate right (circular right shift) operation for uint32 */ export function rotr(word, shift) { return (word << (32 - shift)) | (word >>> shift); } /** The rotate left (circular left shift) operation for uint32 */ export function rotl(word, shift) { return (word << shift) | ((word >>> (32 - shift)) >>> 0); } /** Is current platform little-endian? Most are. Big-Endian platform: IBM */ export const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)(); /** The byte swap operation for uint32 */ export function byteSwap(word) { return (((word << 24) & 0xff000000) | ((word << 8) & 0xff0000) | ((word >>> 8) & 0xff00) | ((word >>> 24) & 0xff)); } /** Conditionally byte swap if on a big-endian platform */ export const swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n); /** In place byte swap for Uint32Array */ export function byteSwap32(arr) { for (let i = 0; i < arr.length; i++) { arr[i] = byteSwap(arr[i]); } return arr; } export const swap32IfBE = isLE ? (u) => u : byteSwap32; // Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex const hasHexBuiltin = /* @__PURE__ */ (() => // @ts-ignore typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')(); // Array where index 0xf0 (240) is mapped to string 'f0' const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); /** * Convert byte array to hex string. Uses built-in function, when available. * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' */ export function bytesToHex(bytes) { abytes(bytes); // @ts-ignore if (hasHexBuiltin) return bytes.toHex(); // pre-caching improves the speed 6x let hex = ''; for (let i = 0; i < bytes.length; i++) { hex += hexes[bytes[i]]; } return hex; } // We use optimized technique to convert hex string to byte array const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; function asciiToBase16(ch) { if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48 if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10) if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10) return; } /** * Convert hex string to byte array. Uses built-in function, when available. * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) */ export function hexToBytes(hex) { if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex); // @ts-ignore if (hasHexBuiltin) return Uint8Array.fromHex(hex); const hl = hex.length; const al = hl / 2; if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl); const array = new Uint8Array(al); for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { const n1 = asciiToBase16(hex.charCodeAt(hi)); const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); if (n1 === undefined || n2 === undefined) { const char = hex[hi] + hex[hi + 1]; throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); } array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 } return array; } /** * There is no setImmediate in browser and setTimeout is slow. * Call of async fn will return Promise, which will be fullfiled only on * next scheduler queue processing step and this is exactly what we need. */ export const nextTick = async () => { }; /** Returns control to thread each 'tick' ms to avoid blocking. */ export async function asyncLoop(iters, tick, cb) { let ts = Date.now(); for (let i = 0; i < iters; i++) { cb(i); // Date.now() is not monotonic, so in case if clock goes backwards we return return control too const diff = Date.now() - ts; if (diff >= 0 && diff < tick) continue; await nextTick(); ts += diff; } } /** * Converts string to bytes using UTF8 encoding. * Built-in doesn't validate input to be string: we do the check. * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99]) */ export function utf8ToBytes(str) { if (typeof str !== 'string') throw new Error('string expected'); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } /** * Helper for KDFs: consumes uint8array or string. * When string is passed, does utf8 decoding, using TextDecoder. */ export function kdfInputToBytes(data, errorTitle = '') { if (typeof data === 'string') return utf8ToBytes(data); return abytes(data, undefined, errorTitle); } /** Copies several Uint8Arrays into one. */ export function concatBytes(...arrays) { let sum = 0; for (let i = 0; i < arrays.length; i++) { const a = arrays[i]; abytes(a); sum += a.length; } const res = new Uint8Array(sum); for (let i = 0, pad = 0; i < arrays.length; i++) { const a = arrays[i]; res.set(a, pad); pad += a.length; } return res; } /** Merges default options and passed options. */ export function checkOpts(defaults, opts) { if (opts !== undefined && {}.toString.call(opts) !== '[object Object]') throw new Error('options must be object or undefined'); const merged = Object.assign(defaults, opts); return merged; } /** Creates function with outputLen, blockLen, create properties from a class constructor. */ export function createHasher(hashCons, info = {}) { const hashC = (msg, opts) => hashCons(opts).update(msg).digest(); const tmp = hashCons(undefined); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = (opts) => hashCons(opts); Object.assign(hashC, info); return Object.freeze(hashC); } /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ export function randomBytes(bytesLength = 32) { const cr = typeof globalThis === 'object' ? globalThis.crypto : null; if (typeof cr?.getRandomValues !== 'function') throw new Error('crypto.getRandomValues must be defined'); return cr.getRandomValues(new Uint8Array(bytesLength)); } /** Creates OID opts for NIST hashes, with prefix 06 09 60 86 48 01 65 03 04 02. */ export const oidNist = (suffix) => ({ oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]), }); //# sourceMappingURL=utils.js.map
Save
cmd:
run