pure-md5 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -24
- package/dist/adapters/ie11.cjs +1 -2
- package/dist/adapters/ie11.js +1 -2
- package/dist/adapters/node.cjs +1 -2
- package/dist/adapters/node.js +1 -2
- package/dist/adapters/webcrypto.cjs +1 -2
- package/dist/adapters/webcrypto.js +1 -2
- package/dist/index.cjs +1 -2
- package/dist/index.d.ts +149 -5
- package/dist/index.js +3 -2
- package/dist/md5.cjs +1 -0
- package/dist/md5.d.ts +20 -0
- package/dist/md5.js +1 -0
- package/dist/stream/md5-stream.cjs +1 -2
- package/dist/stream/md5-stream.js +1 -2
- package/dist/stream/whatwg-stream.cjs +1 -2
- package/dist/stream/whatwg-stream.js +1 -2
- package/dist/utils/detect.cjs +1 -2
- package/dist/utils/detect.js +3 -2
- package/package.json +10 -15
- package/pure-md5-0.2.1.tgz +0 -0
- package/test-tree-shake.mjs +12 -0
- package/.aliases +0 -19
- package/.bash_profile +0 -12
- package/.bash_prompt +0 -56
- package/.changeset/README.md +0 -32
- package/.changeset/config.json +0 -16
- package/.continue/mcpServers/new-mcp-server.yaml +0 -10
- package/.continue/rules +0 -29
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
- package/.github/ISSUE_TEMPLATE/documentation.md +0 -20
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -35
- package/.github/workflows/npm-publish.yml +0 -33
- package/.github/workflows/release.yml +0 -42
- package/CHANGELOG.md +0 -9
- package/CONTRIBUTING.md +0 -203
- package/MIGRATION_GUIDE_STREAMS.md +0 -374
- package/STREAM_API.md +0 -582
- package/STREAM_BENCHMARKS.md +0 -232
- package/STREAM_EXAMPLES.md +0 -669
- package/STREAM_OPTIMIZATION_REPORT.md +0 -136
- package/STREAM_TROUBLESHOOTING.md +0 -537
- package/WEB_CRYPTO_TESTS_SUMMARY.md +0 -140
- package/WHATWG_STREAMS.md +0 -191
- package/__tests__/adapters/node-crypto.test.ts +0 -167
- package/__tests__/adapters/web-crypto-node.test.ts +0 -73
- package/__tests__/adapters/web-crypto.test.ts +0 -195
- package/__tests__/add32.test.ts +0 -33
- package/__tests__/fallback.test.ts +0 -345
- package/__tests__/hex.test.ts +0 -38
- package/__tests__/hex_chr.test.ts +0 -20
- package/__tests__/index.test.ts +0 -87
- package/__tests__/integration/fixtures/test-file.txt +0 -1
- package/__tests__/integration/md5-stream-file.test.ts +0 -293
- package/__tests__/integration/node-crypto-file.test.ts +0 -86
- package/__tests__/integration/web-crypto.test.ts +0 -38
- package/__tests__/md51.test.ts +0 -73
- package/__tests__/md5block.test.ts +0 -61
- package/__tests__/md5cycle.test.ts +0 -48
- package/__tests__/round-functions.test.ts +0 -87
- package/__tests__/stream/fs-utils.test.ts +0 -209
- package/__tests__/stream/md5-stream-edge-cases.test.ts +0 -461
- package/__tests__/stream/md5-stream.test.ts +0 -418
- package/__tests__/stream/whatwg-stream.test.ts +0 -355
- package/__tests__/stream/whatwg-stream.test.ts.bak2 +0 -335
- package/benchmarks/md5-stream.bench.ts +0 -212
- package/benchmarks/whatwg-stream.bench.ts +0 -180
- package/dist/adapters/ie11.cjs.map +0 -1
- package/dist/adapters/ie11.js.map +0 -1
- package/dist/adapters/node.cjs.map +0 -1
- package/dist/adapters/node.js.map +0 -1
- package/dist/adapters/webcrypto.cjs.map +0 -1
- package/dist/adapters/webcrypto.js.map +0 -1
- package/dist/chunk-2YXXFGBV.js +0 -2
- package/dist/chunk-2YXXFGBV.js.map +0 -1
- package/dist/chunk-4KSCMS4Q.js +0 -2
- package/dist/chunk-4KSCMS4Q.js.map +0 -1
- package/dist/chunk-6P2QV5SR.js +0 -4
- package/dist/chunk-6P2QV5SR.js.map +0 -1
- package/dist/chunk-G5WHEAIQ.js +0 -2
- package/dist/chunk-G5WHEAIQ.js.map +0 -1
- package/dist/chunk-H2K353LR.js +0 -2
- package/dist/chunk-H2K353LR.js.map +0 -1
- package/dist/chunk-JKVD5LHZ.js +0 -2
- package/dist/chunk-JKVD5LHZ.js.map +0 -1
- package/dist/chunk-NWQ4N5RX.js +0 -2
- package/dist/chunk-NWQ4N5RX.js.map +0 -1
- package/dist/chunk-PHZ7FTYF.js +0 -2
- package/dist/chunk-PHZ7FTYF.js.map +0 -1
- package/dist/chunk-PNZTVQA7.js +0 -2
- package/dist/chunk-PNZTVQA7.js.map +0 -1
- package/dist/chunk-R4JB5MBR.js +0 -2
- package/dist/chunk-R4JB5MBR.js.map +0 -1
- package/dist/chunk-VFOAY6XI.js +0 -2
- package/dist/chunk-VFOAY6XI.js.map +0 -1
- package/dist/chunk-XB5BQIEX.js +0 -2
- package/dist/chunk-XB5BQIEX.js.map +0 -1
- package/dist/core/index.cjs +0 -2
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -19
- package/dist/core/index.d.ts +0 -19
- package/dist/core/index.js +0 -2
- package/dist/core/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -84
- package/dist/index.js.map +0 -1
- package/dist/stream/adapter.cjs +0 -2
- package/dist/stream/adapter.cjs.map +0 -1
- package/dist/stream/adapter.d.cts +0 -63
- package/dist/stream/adapter.d.ts +0 -63
- package/dist/stream/adapter.js +0 -2
- package/dist/stream/adapter.js.map +0 -1
- package/dist/stream/fs-utils.cjs +0 -2
- package/dist/stream/fs-utils.cjs.map +0 -1
- package/dist/stream/fs-utils.d.cts +0 -137
- package/dist/stream/fs-utils.d.ts +0 -137
- package/dist/stream/fs-utils.js +0 -2
- package/dist/stream/fs-utils.js.map +0 -1
- package/dist/stream/index.cjs +0 -2
- package/dist/stream/index.cjs.map +0 -1
- package/dist/stream/index.d.cts +0 -4
- package/dist/stream/index.d.ts +0 -4
- package/dist/stream/index.js +0 -2
- package/dist/stream/index.js.map +0 -1
- package/dist/stream/light/index.cjs +0 -2
- package/dist/stream/light/index.cjs.map +0 -1
- package/dist/stream/light/index.d.cts +0 -4
- package/dist/stream/light/index.d.ts +0 -4
- package/dist/stream/light/index.js +0 -2
- package/dist/stream/light/index.js.map +0 -1
- package/dist/stream/md5-stream.cjs.map +0 -1
- package/dist/stream/md5-stream.js.map +0 -1
- package/dist/stream/whatwg-stream.cjs.map +0 -1
- package/dist/stream/whatwg-stream.js.map +0 -1
- package/dist/types-edGoGJ5V.d.cts +0 -42
- package/dist/types-edGoGJ5V.d.ts +0 -42
- package/dist/utils/detect.cjs.map +0 -1
- package/dist/utils/detect.js.map +0 -1
- package/planning/03-optimization-size-tree-shaking/01-es-modules-tree-shaking.md +0 -152
- package/planning/03-optimization-size-tree-shaking/02-consolidate-modules.md +0 -65
- package/planning/03-optimization-size-tree-shaking/03-remove-duplicate-add32.md +0 -93
- package/planning/03-optimization-size-tree-shaking/04-remove-runtime-check.md +0 -102
- package/planning/03-optimization-size-tree-shaking/05-optimize-loops-performance.md +0 -107
- package/planning/03-optimization-size-tree-shaking/06-tsup-formats-configuration.md +0 -227
- package/planning/03-optimization-size-tree-shaking/07-multiple-build-formats.md +0 -228
- package/planning/03-optimization-size-tree-shaking/08-benchmarks-metrics.md +0 -34
- package/planning/03-optimization-size-tree-shaking/MIGRATION_GUIDE.md +0 -260
- package/planning/03-optimization-size-tree-shaking/README.md +0 -173
- package/planning/03-optimization-size-tree-shaking/SUMMARY.md +0 -168
- package/planning/04-adapter-backend/03-backend-web-crypto.md +0 -149
- package/planning/04-adapter-backend/04-backend-node-crypto.md +0 -181
- package/planning/04-adapter-backend/05-backend-pure-js.md +0 -174
- package/planning/04-adapter-backend/06-backend-ie11.md +0 -158
- package/planning/04-adapter-backend/07-detection-environment.md +0 -232
- package/planning/04-adapter-backend/08-detection-backend.md +0 -210
- package/planning/04-adapter-backend/09-adapter-unified.md +0 -255
- package/planning/04-adapter-backend/10-fallback-mechanism.md +0 -333
- package/planning/04-adapter-backend/11-tests-backend-web-crypto.md +0 -191
- package/planning/04-adapter-backend/12-tests-backend-node-crypto.md +0 -222
- package/planning/04-adapter-backend/README.md +0 -45
- package/planning/05-documentation-publishing/01-README-optimization.md +0 -105
- package/planning/05-documentation-publishing/02-VitePress-site-evaluation.md +0 -136
- package/planning/05-documentation-publishing/03-Changeset-setup.md +0 -192
- package/planning/05-documentation-publishing/04-GitHub-templates.md +0 -252
- package/planning/05-documentation-publishing/README.md +0 -22
- package/planning/05-documentation-publishing/STATUS.md +0 -222
- package/planning/prd.md +0 -405
- package/planning/streams/01-create-md5stream-class.md +0 -69
- package/planning/streams/02-create-factory-api.md +0 -65
- package/planning/streams/03-fs-integration.md +0 -37
- package/planning/streams/04-whatwg-streams-support.md +0 -37
- package/planning/streams/05-audit-optimization.md +0 -121
- package/planning/streams/06-comprehensive-tests-docs.md +0 -137
- package/planning/streams/07-architecture-integration.md +0 -38
- package/planning/streams/README.md +0 -98
- package/tsup.config.ts +0 -24
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ pnpm add pure-md5
|
|
|
27
27
|
### Basic Usage
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
|
-
import { md5 } from 'pure-md5';
|
|
30
|
+
import { md5 } from 'pure-md5/md5';
|
|
31
31
|
|
|
32
32
|
const hash = md5('hello');
|
|
33
33
|
console.log(hash); // "5d41402abc4b2a76b9719d911017c592"
|
|
@@ -50,7 +50,7 @@ fs.createReadStream('large-file.bin').pipe(stream);
|
|
|
50
50
|
## ✨ Features
|
|
51
51
|
|
|
52
52
|
- ⚡ **Zero Dependencies** - No external dependencies, ever
|
|
53
|
-
- 📦 **Tiny Bundle** -
|
|
53
|
+
- 📦 **Tiny Bundle** - ~1.4KB gzipped for md5() only (with tree-shaking), ~6KB for full bundle
|
|
54
54
|
- 🎯 **Multiple APIs** - Simple, streaming, and promise-based
|
|
55
55
|
- 🦺 **TypeScript Ready** - Full type definitions included
|
|
56
56
|
- 🔌 **Adapter System** - Automatic detection (WebCrypto, Node.js, Pure JS)
|
|
@@ -80,16 +80,10 @@ fs.createReadStream('large-file.bin').pipe(stream);
|
|
|
80
80
|
Compute MD5 hash of a string or buffer.
|
|
81
81
|
|
|
82
82
|
```javascript
|
|
83
|
-
import { md5 } from 'pure-md5';
|
|
84
|
-
|
|
85
|
-
// String input
|
|
86
|
-
md5('hello'); // "5d41402abc4b2a76b9719d911017c592"
|
|
83
|
+
import { md5 } from 'pure-md5/md5'; // Tree-shakeable, ~1.4KB
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// Custom encoding
|
|
92
|
-
md5('hello', 'hex'); // "5d41402abc4b2a76b9719d911017c592"
|
|
85
|
+
const hash = md5('hello');
|
|
86
|
+
console.log(hash); // "5d41402abc4b2a76b9719d911017c592"
|
|
93
87
|
```
|
|
94
88
|
|
|
95
89
|
### Streaming API
|
|
@@ -199,14 +193,31 @@ console.log('Verified:', isVerified); // true or false
|
|
|
199
193
|
|
|
200
194
|
## 📊 Comparison with Alternatives
|
|
201
195
|
|
|
202
|
-
| Feature | pure-md5 | crypto-js | js-md4 | Node.js crypto |
|
|
203
|
-
|
|
204
|
-
| Bundle Size |
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
|
|
|
208
|
-
|
|
|
209
|
-
|
|
|
196
|
+
| Feature | pure-md5 | pvorb/node-md5 | crypto-js | js-md4 | Node.js crypto |
|
|
197
|
+
|---------|----------|----------------|-----------|--------|----------------|
|
|
198
|
+
| Bundle Size (md5 only) | ~1.4KB¹ | ~3KB | ~4KB | ~2KB | N/A |
|
|
199
|
+
| Bundle Size (full) | ~6KB¹ | ~3KB | ~4KB | ~2KB | N/A |
|
|
200
|
+
| Dependencies | 0 | 0 | 0 | 0 | 0 |
|
|
201
|
+
| Streaming | ✅ | ❌ | ❌ | ❌ | ✅ |
|
|
202
|
+
| Browser Support | ✅ | ❌ | ✅ | ✅ | ❌ |
|
|
203
|
+
| TypeScript | ✅ | ❌ | ❌ | ⚠️ | ❌ |
|
|
204
|
+
| Zero Config | ✅ | ❌² | ✅ | ❌ | ✅ |
|
|
205
|
+
| Tree-shaking | ✅ | ❌ | ❌ | ❌ | N/A |
|
|
206
|
+
| Pure JS (no Node) | ✅ | ❌ | ✅ | ✅ | ❌ |
|
|
207
|
+
|
|
208
|
+
¹ **With tree-shaking**: Only import what you use!
|
|
209
|
+
² **Requires Node.js environment** - not browser-compatible
|
|
210
|
+
|
|
211
|
+
### Why choose pure-md5 over pvorb/node-md5?
|
|
212
|
+
|
|
213
|
+
1. **Browser Support**: pvorb/node-md5 only works in Node.js, while pure-md5 works everywhere
|
|
214
|
+
2. **Tree-shaking**: pure-md5 supports modern tree-shaking for smaller bundles
|
|
215
|
+
3. **Streaming**: built-in streaming API for large files in pure-md5
|
|
216
|
+
4. **TypeScript**: first-class TypeScript support with full type definitions
|
|
217
|
+
5. **Zero dependencies**: truly zero-dependency implementation
|
|
218
|
+
6. **Modern API**: cleaner, more intuitive interface with promise-based options
|
|
219
|
+
|
|
220
|
+
pvorb/node-md5 is still a good choice if you only need Node.js and prefer its API style.
|
|
210
221
|
|
|
211
222
|
---
|
|
212
223
|
|
|
@@ -228,12 +239,15 @@ import { md5 } from 'pure-md5';
|
|
|
228
239
|
|
|
229
240
|
### Manual Adapter Selection
|
|
230
241
|
|
|
242
|
+
Use adapter backends directly when you need explicit control:
|
|
243
|
+
|
|
231
244
|
```javascript
|
|
232
|
-
import {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
245
|
+
import { NodeCryptoBackend, WebCryptoBackend, PureJSBackend } from 'pure-md5';
|
|
246
|
+
|
|
247
|
+
// Create backend instances
|
|
248
|
+
const nodeBackend = new NodeCryptoBackend();
|
|
249
|
+
const hash = await nodeBackend.hash('hello');
|
|
250
|
+
console.log(hash);
|
|
237
251
|
```
|
|
238
252
|
|
|
239
253
|
---
|
package/dist/adapters/ie11.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var n=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let r=window;return typeof r.msCrypto<"u"&&typeof r.msCrypto.subtle<"u"&&typeof r.msCrypto.subtle.digest=="function"}async hash(r){let e=new TextEncoder().encode(r);return await this.hashBinary(e)}async hashBinary(r){let t=window,e=r instanceof Uint8Array?r.buffer:r,i=await t.msCrypto.subtle.digest("MD5",e);return this.bufferToHex(i)}bufferToHex(r){return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}update(r){throw new Error("msCrypto does not support streaming updates")}digest(r){throw new Error("msCrypto does not support streaming")}reset(){}};exports.IE11Backend=n
|
|
2
|
-
//# sourceMappingURL=ie11.cjs.map
|
|
1
|
+
'use strict';var n=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let r=window;return typeof r.msCrypto<"u"&&typeof r.msCrypto.subtle<"u"&&typeof r.msCrypto.subtle.digest=="function"}async hash(r){let e=new TextEncoder().encode(r);return await this.hashBinary(e)}async hashBinary(r){let t=window,e=r instanceof Uint8Array?r.buffer:r,i=await t.msCrypto.subtle.digest("MD5",e);return this.bufferToHex(i)}bufferToHex(r){return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}update(r){throw new Error("msCrypto does not support streaming updates")}digest(r){throw new Error("msCrypto does not support streaming")}reset(){}};exports.IE11Backend=n;
|
package/dist/adapters/ie11.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=ie11.js.map
|
|
1
|
+
var n=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let r=window;return typeof r.msCrypto<"u"&&typeof r.msCrypto.subtle<"u"&&typeof r.msCrypto.subtle.digest=="function"}async hash(r){let e=new TextEncoder().encode(r);return await this.hashBinary(e)}async hashBinary(r){let t=window,e=r instanceof Uint8Array?r.buffer:r,i=await t.msCrypto.subtle.digest("MD5",e);return this.bufferToHex(i)}bufferToHex(r){return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}update(r){throw new Error("msCrypto does not support streaming updates")}digest(r){throw new Error("msCrypto does not support streaming")}reset(){}};export{n as IE11Backend};
|
package/dist/adapters/node.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var n=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var i=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof n("crypto").createHash=="function"}catch{return false}}hash(r){return n("crypto").createHash("md5").update(r).digest("hex")}async hashBinary(r){let t=n("crypto"),o=r instanceof Uint8Array?r:new Uint8Array(r);return t.createHash("md5").update(o).digest("hex")}update(r){}digest(r){throw new Error("Node crypto streaming not implemented")}reset(){}};exports.NodeCryptoBackend=i
|
|
2
|
-
//# sourceMappingURL=node.cjs.map
|
|
1
|
+
'use strict';var n=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var i=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof n("crypto").createHash=="function"}catch{return false}}hash(r){return n("crypto").createHash("md5").update(r).digest("hex")}async hashBinary(r){let t=n("crypto"),o=r instanceof Uint8Array?r:new Uint8Array(r);return t.createHash("md5").update(o).digest("hex")}update(r){}digest(r){throw new Error("Node crypto streaming not implemented")}reset(){}};exports.NodeCryptoBackend=i;
|
package/dist/adapters/node.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=node.js.map
|
|
1
|
+
var n=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var i=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof n("crypto").createHash=="function"}catch{return false}}hash(r){return n("crypto").createHash("md5").update(r).digest("hex")}async hashBinary(r){let t=n("crypto"),o=r instanceof Uint8Array?r:new Uint8Array(r);return t.createHash("md5").update(o).digest("hex")}update(r){}digest(r){throw new Error("Node crypto streaming not implemented")}reset(){}};export{i as NodeCryptoBackend};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var C="0123456789abcdef".split(""),p=C;function B(o){let n="";for(let m=0;m<4;m++)n+=p[o>>m*8+4&15]+p[o>>m*8&15];return n}function P(o){let n=o.length,m=new Array(n);for(let e=0;e<n;e++)m[e]=B(o[e]);return m.join("")}var g=P;function D(o,n){return o+n&4294967295}var c=D;function U(o,n,m,e,r){let t=r||c;return n=t(t(n,o),t(m,e)),n}function _(o,n,m,e){var t=(e||c)(o<<n|o>>>32-n,m);return t}function s(o,n,m,e,r,t,u){return n=U(o,n,e,t,u),_(n,r,m,u)}function h(o,n,m,e,r,t,u,i){return s(m&e|~m&r,n,m,t,u,i,o)}function y(o,n,m,e,r,t,u,i){return s(m&r|e&~r,n,m,t,u,i,o)}function A(o,n,m,e,r,t,u,i){return s(m^e^r,n,m,t,u,i,o)}function x(o,n,m,e,r,t,u,i){return s(e^(m|~r),n,m,t,u,i,o)}function j(o,n,m){typeof m>"u"&&(m=c);let e=o[0],r=o[1],t=o[2],u=o[3],i=h.bind(null,m);e=i(e,r,t,u,n[0],7,-680876936),u=i(u,e,r,t,n[1],12,-389564586),t=i(t,u,e,r,n[2],17,606105819),r=i(r,t,u,e,n[3],22,-1044525330),e=i(e,r,t,u,n[4],7,-176418897),u=i(u,e,r,t,n[5],12,1200080426),t=i(t,u,e,r,n[6],17,-1473231341),r=i(r,t,u,e,n[7],22,-45705983),e=i(e,r,t,u,n[8],7,1770035416),u=i(u,e,r,t,n[9],12,-1958414417),t=i(t,u,e,r,n[10],17,-42063),r=i(r,t,u,e,n[11],22,-1990404162),e=i(e,r,t,u,n[12],7,1804603682),u=i(u,e,r,t,n[13],12,-40341101),t=i(t,u,e,r,n[14],17,-1502002290),r=i(r,t,u,e,n[15],22,1236535329);let d=y.bind(null,m);e=d(e,r,t,u,n[1],5,-165796510),u=d(u,e,r,t,n[6],9,-1069501632),t=d(t,u,e,r,n[11],14,643717713),r=d(r,t,u,e,n[0],20,-373897302),e=d(e,r,t,u,n[5],5,-701558691),u=d(u,e,r,t,n[10],9,38016083),t=d(t,u,e,r,n[15],14,-660478335),r=d(r,t,u,e,n[4],20,-405537848),e=d(e,r,t,u,n[9],5,568446438),u=d(u,e,r,t,n[14],9,-1019803690),t=d(t,u,e,r,n[3],14,-187363961),r=d(r,t,u,e,n[8],20,1163531501),e=d(e,r,t,u,n[13],5,-1444681467),u=d(u,e,r,t,n[2],9,-51403784),t=d(t,u,e,r,n[7],14,1735328473),r=d(r,t,u,e,n[12],20,-1926607734);let b=A.bind(null,m);e=b(e,r,t,u,n[5],4,-378558),u=b(u,e,r,t,n[8],11,-2022574463),t=b(t,u,e,r,n[11],16,1839030562),r=b(r,t,u,e,n[14],23,-35309556),e=b(e,r,t,u,n[1],4,-1530992060),u=b(u,e,r,t,n[4],11,1272893353),t=b(t,u,e,r,n[7],16,-155497632),r=b(r,t,u,e,n[10],23,-1094730640),e=b(e,r,t,u,n[13],4,681279174),u=b(u,e,r,t,n[0],11,-358537222),t=b(t,u,e,r,n[3],16,-722521979),r=b(r,t,u,e,n[6],23,76029189),e=b(e,r,t,u,n[9],4,-640364487),u=b(u,e,r,t,n[12],11,-421815835),t=b(t,u,e,r,n[15],16,530742520),r=b(r,t,u,e,n[2],23,-995338651);let f=x.bind(null,m);e=f(e,r,t,u,n[0],6,-198630844),u=f(u,e,r,t,n[7],10,1126891415),t=f(t,u,e,r,n[14],15,-1416354905),r=f(r,t,u,e,n[5],21,-57434055),e=f(e,r,t,u,n[12],6,1700485571),u=f(u,e,r,t,n[3],10,-1894986606),t=f(t,u,e,r,n[10],15,-1051523),r=f(r,t,u,e,n[1],21,-2054922799),e=f(e,r,t,u,n[8],6,1873313359),u=f(u,e,r,t,n[15],10,-30611744),t=f(t,u,e,r,n[6],15,-1560198380),r=f(r,t,u,e,n[13],21,1309151649),e=f(e,r,t,u,n[4],6,-145523070),u=f(u,e,r,t,n[11],10,-1120210379),t=f(t,u,e,r,n[2],15,718787259),r=f(r,t,u,e,n[9],21,-343485551),o[0]=m(e,o[0]),o[1]=m(r,o[1]),o[2]=m(t,o[2]),o[3]=m(u,o[3]);}var l=j;function E(o){let n=[];for(let m=0;m<64;m+=4)n[m>>2]=(o.charCodeAt(m)||0)+((o.charCodeAt(m+1)||0)<<8)+((o.charCodeAt(m+2)||0)<<16)+((o.charCodeAt(m+3)||0)<<24);return n}var F=E;function I(o,n){let m=o.length,e=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=m;r+=64)l(e,F(o.substring(r-64,r)),n);o=o.substring(r-64);var t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=o.length;for(r=0;r<u;r++)t[r>>2]|=(o.charCodeAt(r)&255)<<(r%4<<3);if(t[r>>2]|=128<<(r%4<<3),r>55)for(l(e,t,n),r=16;r--;)t[r]=0;return t[14]=m*8,l(e,t,n),e}var v=I;function a(o){return g(v(o,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return a(n)}async hashBinary(n){let m=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return a(m)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};exports.WebCryptoBackend=w
|
|
2
|
-
//# sourceMappingURL=webcrypto.cjs.map
|
|
1
|
+
'use strict';var C="0123456789abcdef".split(""),p=C;function B(o){let n="";for(let m=0;m<4;m++)n+=p[o>>m*8+4&15]+p[o>>m*8&15];return n}function P(o){let n=o.length,m=new Array(n);for(let e=0;e<n;e++)m[e]=B(o[e]);return m.join("")}var g=P;function D(o,n){return o+n&4294967295}var c=D;function U(o,n,m,e,r){let t=r||c;return n=t(t(n,o),t(m,e)),n}function _(o,n,m,e){var t=(e||c)(o<<n|o>>>32-n,m);return t}function s(o,n,m,e,r,t,u){return n=U(o,n,e,t,u),_(n,r,m,u)}function h(o,n,m,e,r,t,u,i){return s(m&e|~m&r,n,m,t,u,i,o)}function y(o,n,m,e,r,t,u,i){return s(m&r|e&~r,n,m,t,u,i,o)}function A(o,n,m,e,r,t,u,i){return s(m^e^r,n,m,t,u,i,o)}function x(o,n,m,e,r,t,u,i){return s(e^(m|~r),n,m,t,u,i,o)}function j(o,n,m){typeof m>"u"&&(m=c);let e=o[0],r=o[1],t=o[2],u=o[3],i=h.bind(null,m);e=i(e,r,t,u,n[0],7,-680876936),u=i(u,e,r,t,n[1],12,-389564586),t=i(t,u,e,r,n[2],17,606105819),r=i(r,t,u,e,n[3],22,-1044525330),e=i(e,r,t,u,n[4],7,-176418897),u=i(u,e,r,t,n[5],12,1200080426),t=i(t,u,e,r,n[6],17,-1473231341),r=i(r,t,u,e,n[7],22,-45705983),e=i(e,r,t,u,n[8],7,1770035416),u=i(u,e,r,t,n[9],12,-1958414417),t=i(t,u,e,r,n[10],17,-42063),r=i(r,t,u,e,n[11],22,-1990404162),e=i(e,r,t,u,n[12],7,1804603682),u=i(u,e,r,t,n[13],12,-40341101),t=i(t,u,e,r,n[14],17,-1502002290),r=i(r,t,u,e,n[15],22,1236535329);let d=y.bind(null,m);e=d(e,r,t,u,n[1],5,-165796510),u=d(u,e,r,t,n[6],9,-1069501632),t=d(t,u,e,r,n[11],14,643717713),r=d(r,t,u,e,n[0],20,-373897302),e=d(e,r,t,u,n[5],5,-701558691),u=d(u,e,r,t,n[10],9,38016083),t=d(t,u,e,r,n[15],14,-660478335),r=d(r,t,u,e,n[4],20,-405537848),e=d(e,r,t,u,n[9],5,568446438),u=d(u,e,r,t,n[14],9,-1019803690),t=d(t,u,e,r,n[3],14,-187363961),r=d(r,t,u,e,n[8],20,1163531501),e=d(e,r,t,u,n[13],5,-1444681467),u=d(u,e,r,t,n[2],9,-51403784),t=d(t,u,e,r,n[7],14,1735328473),r=d(r,t,u,e,n[12],20,-1926607734);let b=A.bind(null,m);e=b(e,r,t,u,n[5],4,-378558),u=b(u,e,r,t,n[8],11,-2022574463),t=b(t,u,e,r,n[11],16,1839030562),r=b(r,t,u,e,n[14],23,-35309556),e=b(e,r,t,u,n[1],4,-1530992060),u=b(u,e,r,t,n[4],11,1272893353),t=b(t,u,e,r,n[7],16,-155497632),r=b(r,t,u,e,n[10],23,-1094730640),e=b(e,r,t,u,n[13],4,681279174),u=b(u,e,r,t,n[0],11,-358537222),t=b(t,u,e,r,n[3],16,-722521979),r=b(r,t,u,e,n[6],23,76029189),e=b(e,r,t,u,n[9],4,-640364487),u=b(u,e,r,t,n[12],11,-421815835),t=b(t,u,e,r,n[15],16,530742520),r=b(r,t,u,e,n[2],23,-995338651);let f=x.bind(null,m);e=f(e,r,t,u,n[0],6,-198630844),u=f(u,e,r,t,n[7],10,1126891415),t=f(t,u,e,r,n[14],15,-1416354905),r=f(r,t,u,e,n[5],21,-57434055),e=f(e,r,t,u,n[12],6,1700485571),u=f(u,e,r,t,n[3],10,-1894986606),t=f(t,u,e,r,n[10],15,-1051523),r=f(r,t,u,e,n[1],21,-2054922799),e=f(e,r,t,u,n[8],6,1873313359),u=f(u,e,r,t,n[15],10,-30611744),t=f(t,u,e,r,n[6],15,-1560198380),r=f(r,t,u,e,n[13],21,1309151649),e=f(e,r,t,u,n[4],6,-145523070),u=f(u,e,r,t,n[11],10,-1120210379),t=f(t,u,e,r,n[2],15,718787259),r=f(r,t,u,e,n[9],21,-343485551),o[0]=m(e,o[0]),o[1]=m(r,o[1]),o[2]=m(t,o[2]),o[3]=m(u,o[3]);}var l=j;function E(o){let n=[];for(let m=0;m<64;m+=4)n[m>>2]=(o.charCodeAt(m)||0)+((o.charCodeAt(m+1)||0)<<8)+((o.charCodeAt(m+2)||0)<<16)+((o.charCodeAt(m+3)||0)<<24);return n}var F=E;function I(o,n){let m=o.length,e=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=m;r+=64)l(e,F(o.substring(r-64,r)),n);o=o.substring(r-64);var t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=o.length;for(r=0;r<u;r++)t[r>>2]|=(o.charCodeAt(r)&255)<<(r%4<<3);if(t[r>>2]|=128<<(r%4<<3),r>55)for(l(e,t,n),r=16;r--;)t[r]=0;return t[14]=m*8,l(e,t,n),e}var v=I;function a(o){return g(v(o,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return a(n)}async hashBinary(n){let m=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return a(m)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};exports.WebCryptoBackend=w;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=webcrypto.js.map
|
|
1
|
+
var C="0123456789abcdef".split(""),p=C;function B(o){let n="";for(let m=0;m<4;m++)n+=p[o>>m*8+4&15]+p[o>>m*8&15];return n}function P(o){let n=o.length,m=new Array(n);for(let e=0;e<n;e++)m[e]=B(o[e]);return m.join("")}var g=P;function D(o,n){return o+n&4294967295}var c=D;function U(o,n,m,e,r){let t=r||c;return n=t(t(n,o),t(m,e)),n}function _(o,n,m,e){var t=(e||c)(o<<n|o>>>32-n,m);return t}function s(o,n,m,e,r,t,u){return n=U(o,n,e,t,u),_(n,r,m,u)}function h(o,n,m,e,r,t,u,i){return s(m&e|~m&r,n,m,t,u,i,o)}function y(o,n,m,e,r,t,u,i){return s(m&r|e&~r,n,m,t,u,i,o)}function A(o,n,m,e,r,t,u,i){return s(m^e^r,n,m,t,u,i,o)}function x(o,n,m,e,r,t,u,i){return s(e^(m|~r),n,m,t,u,i,o)}function j(o,n,m){typeof m>"u"&&(m=c);let e=o[0],r=o[1],t=o[2],u=o[3],i=h.bind(null,m);e=i(e,r,t,u,n[0],7,-680876936),u=i(u,e,r,t,n[1],12,-389564586),t=i(t,u,e,r,n[2],17,606105819),r=i(r,t,u,e,n[3],22,-1044525330),e=i(e,r,t,u,n[4],7,-176418897),u=i(u,e,r,t,n[5],12,1200080426),t=i(t,u,e,r,n[6],17,-1473231341),r=i(r,t,u,e,n[7],22,-45705983),e=i(e,r,t,u,n[8],7,1770035416),u=i(u,e,r,t,n[9],12,-1958414417),t=i(t,u,e,r,n[10],17,-42063),r=i(r,t,u,e,n[11],22,-1990404162),e=i(e,r,t,u,n[12],7,1804603682),u=i(u,e,r,t,n[13],12,-40341101),t=i(t,u,e,r,n[14],17,-1502002290),r=i(r,t,u,e,n[15],22,1236535329);let d=y.bind(null,m);e=d(e,r,t,u,n[1],5,-165796510),u=d(u,e,r,t,n[6],9,-1069501632),t=d(t,u,e,r,n[11],14,643717713),r=d(r,t,u,e,n[0],20,-373897302),e=d(e,r,t,u,n[5],5,-701558691),u=d(u,e,r,t,n[10],9,38016083),t=d(t,u,e,r,n[15],14,-660478335),r=d(r,t,u,e,n[4],20,-405537848),e=d(e,r,t,u,n[9],5,568446438),u=d(u,e,r,t,n[14],9,-1019803690),t=d(t,u,e,r,n[3],14,-187363961),r=d(r,t,u,e,n[8],20,1163531501),e=d(e,r,t,u,n[13],5,-1444681467),u=d(u,e,r,t,n[2],9,-51403784),t=d(t,u,e,r,n[7],14,1735328473),r=d(r,t,u,e,n[12],20,-1926607734);let b=A.bind(null,m);e=b(e,r,t,u,n[5],4,-378558),u=b(u,e,r,t,n[8],11,-2022574463),t=b(t,u,e,r,n[11],16,1839030562),r=b(r,t,u,e,n[14],23,-35309556),e=b(e,r,t,u,n[1],4,-1530992060),u=b(u,e,r,t,n[4],11,1272893353),t=b(t,u,e,r,n[7],16,-155497632),r=b(r,t,u,e,n[10],23,-1094730640),e=b(e,r,t,u,n[13],4,681279174),u=b(u,e,r,t,n[0],11,-358537222),t=b(t,u,e,r,n[3],16,-722521979),r=b(r,t,u,e,n[6],23,76029189),e=b(e,r,t,u,n[9],4,-640364487),u=b(u,e,r,t,n[12],11,-421815835),t=b(t,u,e,r,n[15],16,530742520),r=b(r,t,u,e,n[2],23,-995338651);let f=x.bind(null,m);e=f(e,r,t,u,n[0],6,-198630844),u=f(u,e,r,t,n[7],10,1126891415),t=f(t,u,e,r,n[14],15,-1416354905),r=f(r,t,u,e,n[5],21,-57434055),e=f(e,r,t,u,n[12],6,1700485571),u=f(u,e,r,t,n[3],10,-1894986606),t=f(t,u,e,r,n[10],15,-1051523),r=f(r,t,u,e,n[1],21,-2054922799),e=f(e,r,t,u,n[8],6,1873313359),u=f(u,e,r,t,n[15],10,-30611744),t=f(t,u,e,r,n[6],15,-1560198380),r=f(r,t,u,e,n[13],21,1309151649),e=f(e,r,t,u,n[4],6,-145523070),u=f(u,e,r,t,n[11],10,-1120210379),t=f(t,u,e,r,n[2],15,718787259),r=f(r,t,u,e,n[9],21,-343485551),o[0]=m(e,o[0]),o[1]=m(r,o[1]),o[2]=m(t,o[2]),o[3]=m(u,o[3]);}var l=j;function E(o){let n=[];for(let m=0;m<64;m+=4)n[m>>2]=(o.charCodeAt(m)||0)+((o.charCodeAt(m+1)||0)<<8)+((o.charCodeAt(m+2)||0)<<16)+((o.charCodeAt(m+3)||0)<<24);return n}var F=E;function I(o,n){let m=o.length,e=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=m;r+=64)l(e,F(o.substring(r-64,r)),n);o=o.substring(r-64);var t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=o.length;for(r=0;r<u;r++)t[r>>2]|=(o.charCodeAt(r)&255)<<(r%4<<3);if(t[r>>2]|=128<<(r%4<<3),r>55)for(l(e,t,n),r=16;r--;)t[r]=0;return t[14]=m*8,l(e,t,n),e}var v=I;function a(o){return g(v(o,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return a(n)}async hashBinary(n){let m=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return a(m)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};export{w as WebCryptoBackend};
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
'use strict';var stream=require('stream'),D=require('fs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var D__default=/*#__PURE__*/_interopDefault(D);var N=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Z="0123456789abcdef".split(""),O=Z;function ee(i){let e="";for(let n=0;n<4;n++)e+=O[i>>n*8+4&15]+O[i>>n*8&15];return e}function re(i){let e=i.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=ee(i[r]);return n.join("")}var S=re;function te(i,e){return i+e&4294967295}var b=te;function ne(i,e,n,r,t){let s=t||b;return e=s(s(e,i),s(n,r)),e}function se(i,e,n,r){var s=(r||b)(i<<e|i>>>32-e,n);return s}function C(i,e,n,r,t,s,a){return e=ne(i,e,r,s,a),se(e,t,n,a)}function I(i,e,n,r,t,s,a,o){return C(n&r|~n&t,e,n,s,a,o,i)}function L(i,e,n,r,t,s,a,o){return C(n&t|r&~t,e,n,s,a,o,i)}function $(i,e,n,r,t,s,a,o){return C(n^r^t,e,n,s,a,o,i)}function _(i,e,n,r,t,s,a,o){return C(r^(n|~t),e,n,s,a,o,i)}function ie(i,e,n){typeof n>"u"&&(n=b);let r=i[0],t=i[1],s=i[2],a=i[3],o=I.bind(null,n);r=o(r,t,s,a,e[0],7,-680876936),a=o(a,r,t,s,e[1],12,-389564586),s=o(s,a,r,t,e[2],17,606105819),t=o(t,s,a,r,e[3],22,-1044525330),r=o(r,t,s,a,e[4],7,-176418897),a=o(a,r,t,s,e[5],12,1200080426),s=o(s,a,r,t,e[6],17,-1473231341),t=o(t,s,a,r,e[7],22,-45705983),r=o(r,t,s,a,e[8],7,1770035416),a=o(a,r,t,s,e[9],12,-1958414417),s=o(s,a,r,t,e[10],17,-42063),t=o(t,s,a,r,e[11],22,-1990404162),r=o(r,t,s,a,e[12],7,1804603682),a=o(a,r,t,s,e[13],12,-40341101),s=o(s,a,r,t,e[14],17,-1502002290),t=o(t,s,a,r,e[15],22,1236535329);let c=L.bind(null,n);r=c(r,t,s,a,e[1],5,-165796510),a=c(a,r,t,s,e[6],9,-1069501632),s=c(s,a,r,t,e[11],14,643717713),t=c(t,s,a,r,e[0],20,-373897302),r=c(r,t,s,a,e[5],5,-701558691),a=c(a,r,t,s,e[10],9,38016083),s=c(s,a,r,t,e[15],14,-660478335),t=c(t,s,a,r,e[4],20,-405537848),r=c(r,t,s,a,e[9],5,568446438),a=c(a,r,t,s,e[14],9,-1019803690),s=c(s,a,r,t,e[3],14,-187363961),t=c(t,s,a,r,e[8],20,1163531501),r=c(r,t,s,a,e[13],5,-1444681467),a=c(a,r,t,s,e[2],9,-51403784),s=c(s,a,r,t,e[7],14,1735328473),t=c(t,s,a,r,e[12],20,-1926607734);let u=$.bind(null,n);r=u(r,t,s,a,e[5],4,-378558),a=u(a,r,t,s,e[8],11,-2022574463),s=u(s,a,r,t,e[11],16,1839030562),t=u(t,s,a,r,e[14],23,-35309556),r=u(r,t,s,a,e[1],4,-1530992060),a=u(a,r,t,s,e[4],11,1272893353),s=u(s,a,r,t,e[7],16,-155497632),t=u(t,s,a,r,e[10],23,-1094730640),r=u(r,t,s,a,e[13],4,681279174),a=u(a,r,t,s,e[0],11,-358537222),s=u(s,a,r,t,e[3],16,-722521979),t=u(t,s,a,r,e[6],23,76029189),r=u(r,t,s,a,e[9],4,-640364487),a=u(a,r,t,s,e[12],11,-421815835),s=u(s,a,r,t,e[15],16,530742520),t=u(t,s,a,r,e[2],23,-995338651);let f=_.bind(null,n);r=f(r,t,s,a,e[0],6,-198630844),a=f(a,r,t,s,e[7],10,1126891415),s=f(s,a,r,t,e[14],15,-1416354905),t=f(t,s,a,r,e[5],21,-57434055),r=f(r,t,s,a,e[12],6,1700485571),a=f(a,r,t,s,e[3],10,-1894986606),s=f(s,a,r,t,e[10],15,-1051523),t=f(t,s,a,r,e[1],21,-2054922799),r=f(r,t,s,a,e[8],6,1873313359),a=f(a,r,t,s,e[15],10,-30611744),s=f(s,a,r,t,e[6],15,-1560198380),t=f(t,s,a,r,e[13],21,1309151649),r=f(r,t,s,a,e[4],6,-145523070),a=f(a,r,t,s,e[11],10,-1120210379),s=f(s,a,r,t,e[2],15,718787259),t=f(t,s,a,r,e[9],21,-343485551),i[0]=n(r,i[0]),i[1]=n(t,i[1]),i[2]=n(s,i[2]),i[3]=n(a,i[3]);}var m=ie;function ae(i){let e=[];for(let n=0;n<64;n+=4)e[n>>2]=(i.charCodeAt(n)||0)+((i.charCodeAt(n+1)||0)<<8)+((i.charCodeAt(n+2)||0)<<16)+((i.charCodeAt(n+3)||0)<<24);return e}var G=ae;function oe(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64)m(r,G(i.substring(t-64,t)),e);i=i.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a=i.length;for(t=0;t<a;t++)s[t>>2]|=(i.charCodeAt(t)&255)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(m(r,s,e),t=16;t--;)s[t]=0;return s[14]=n*8,m(r,s,e),r}var z=oe;function ce(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64){let o=ue(i,t-64);m(r,o,e);}let s=n-t+64,a=new Array(16).fill(0);for(let o=0;o<s;o++)a[o>>2]|=(i[n-s+o]&255)<<(o%4<<3);if(a[s>>2]|=128<<(s%4<<3),s>55){m(r,a,e);for(let o=0;o<16;o++)a[o]=0;}return a[14]=n*8,a[15]=0,m(r,a,e),r}function ue(i,e){let n=[];for(let r=0;r<64;r+=4)n[r>>2]=(i[e+r]||0)+((i[e+r+1]||0)<<8)+((i[e+r+2]||0)<<16)+((i[e+r+3]||0)<<24);return n}var K=ce;function l(i){return S(z(i,b))}function q(i){return S(K(i,b))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof N("crypto").createHash=="function"}catch{return false}}hash(e){return N("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let n=N("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return n.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var B=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let n=window,r=e instanceof Uint8Array?e.buffer:e,t=await n.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(t)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var p=class i extends stream.Transform{constructor(n){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=n?.add32||b,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(n,r,t){try{let s=n,a=s.length;if(a===0){t();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,h=Math.min(a,f);for(let d=0;d<h;d++)this.buffer[u+d]=s[d];if(this.state.bufferLength+=h,this.state.bufferLength===64&&this._processBufferBlock(),h===a){t();return}let y=a-h;for(let d=0;d<y;d++)s[d]=s[h+d];let v=Buffer.alloc(y);for(let d=0;d<y;d++)v[d]=s[d];s=v;}let o=Math.floor(s.length/64);for(let u=0;u<o;u++){let f=u*64,h=[];for(let y=0;y<16;y++){let v=f+y*4;h[y]=s[v]+(s[v+1]<<8)+(s[v+2]<<16)+(s[v+3]<<24);}m(this.state.state,h,this.add32),this.state.bytesProcessed+=64;}let c=s.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let u=0;u<c;u++)this.buffer[u]=s[o*64+u];this.state.bufferLength=c;}t();}catch(s){t(s);}}_processBufferBlock(){let n=this.state.buffer,r=[];for(let t=0;t<16;t++){let s=t*4;r[t]=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+(n[s+3]<<24);}m(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(n){try{let{state:r,bufferLength:t,buffer:s}=this.state,a=new Array(16).fill(0);for(let c=0;c<t;c++)a[c>>2]|=(s[c]&255)<<(c%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55){m(r,a,this.add32);for(let c=0;c<16;c++)a[c]=0;}a[14]=(this.state.bytesProcessed+t)*8,a[15]=0,m(r,a,this.add32);let o=S(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+t}),n();}catch(r){n(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(n,r){let t=new i(r),s=E.call(t,n);return {stream:t,result:s}}};function R(i){return new p(i)}async function E(i){return new Promise((e,n)=>{let r=[];i.pipe(this).on("md5",t=>{r.push(t);}).on("error",n).on("finish",()=>{e(r[0]);});})}function j(i,e){let n=new p(e),r=E.call(n,i);return {stream:n,result:r}}var A=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let n=new p;return (await new Promise((t,s)=>{n.on("md5",a=>t(a)).on("error",s).end(e);})).digest}async hashBinary(e){let n=new p,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((s,a)=>{n.on("md5",o=>s(o)).on("error",a).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),n.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream;return n.end(),new Promise((r,t)=>{n.on("md5",s=>{if(e==="buffer"){let a=s.digest,o=[];for(let c=0;c<a.length;c+=2)o.push(parseInt(a.substring(c,c+2),16));r(Buffer.from(o));}else r(s.digest);}).on("error",t);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var k=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let n=l(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(n):n}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let n=[];for(let r=0;r<e.length;r+=2)n.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(n)}};async function de(i){switch(i){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let n=w.isAvailable();return {backend:"nodecrypto",available:n,reason:n?void 0:"Node.js crypto not available"};case "ie11":let r=B.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let t=typeof process<"u"&&process.versions&&"node"in process.versions,s=typeof window<"u";return {backend:"stream",available:t||s,reason:t||s?void 0:"Streams not available"};default:return {backend:i||"unknown",available:false,reason:"Unknown backend"}}}async function x(){let i=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let n of i){let{available:r}=await de(n);r&&e.push(n);}return e}var me=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function F(i){let e=[...me].sort((n,r)=>n.priority-r.priority);for(let{name:n}of e)if(i.includes(n))return n;return "purejs"}var M=class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return new k}}async createBackend(e){let n=e||F(await x());return this.createBackendByName(n)}},le=M.getInstance(),P=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let n=[];for(let r of this.fallbackOrder)try{let t=await this.detector.createBackendByName(r),s=await e(t);return {success:!0,backend:r,data:s}}catch(t){if(n.push({backend:r,error:t}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:n}}return {success:false,backend:"",data:null,errors:n}}async hash(e){return this.execute(async n=>n.hash(e))}async hashBinary(e){return this.execute(async n=>n.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let n of this.fallbackOrder)try{await this.detector.createBackendByName(n),e.push(n);}catch{}return e}getMetrics(){return {}}},be=new P;async function pe(i,e={}){let n=new P;if(e.forceBackend)return (await n.detector.createBackendByName(e.forceBackend)).hash(i);if(e.fallback===false)return (await n.detector.createBackend()).hash(i);let r=await n.hash(i);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let t=r.errors?r.errors.map(s=>`${s.backend}: ${s.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${t}`)}var U=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((n,r)=>n+r.success+r.fail,0)}
|
|
2
2
|
`+Object.entries(this.metrics).map(([,n])=>`${n.success} success, ${n.fail} fail`).join(`
|
|
3
|
-
`)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new U;async function W(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let n;try{n=D__default.default.statSync(i);}catch(t){throw new Error(`Failed to access file ${i}: ${t.message}`)}if(!n.isFile())throw new Error(`Path is not a file: ${i}`);let r=D__default.default.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await T(r,{onProgress:e.onProgress,totalSize:n.size})}finally{r.destroy();}}async function T(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let n=R(),r=0;return e.onProgress&&i.on("data",t=>{r+=t.length,e.onProgress?.(r);}),i.on("error",t=>{n.destroy(t);}),i.on("end",()=>{n.end();}),new Promise((t,s)=>{n.on("md5",a=>{t(a);}).on("error",a=>{s(a);}),i.pipe(n);})}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e={}){return (await T(i,e)).digest}async function Q(i,e,n={}){return (await W(i,n)).digest.toLowerCase()===e.toLowerCase()}function V(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D__default.default.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let n;try{n=D__default.default.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return q(n)}function X(i,e){let n=0;return r=>{if(i>0){let t=Math.min(100,r/i*100);Math.floor(t)!==Math.floor(n)&&(e(t),n=t);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await x();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await x()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:n=>l(n),hashBinary:async n=>l(n instanceof Uint8Array?new TextDecoder().decode(n):new TextDecoder().decode(new Uint8Array(n))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await x(),n=F(e);return this.backend=await this.createBackendByName(n),this.backendName=n,this.backend}};function Ar(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}exports.BackendDetector=M;exports.FallbackManager=P;exports.IE11Backend=B;exports.MD5Stream=p;exports.MetricsCollector=U;exports.NodeCryptoBackend=w;exports.PureJSBackend=k;exports.WebCryptoBackend=g;exports.createMD5Stream=R;exports.createProgressTracker=X;exports.detector=le;exports.fallbackManager=be;exports.fromStream=j;exports.getAllAvailableBackends=x;exports.getBestAvailableBackend=F;exports.hashFile=W;exports.hashFileDigest=J;exports.hashFileStream=T;exports.hashFileStreamDigest=Y;exports.hashFileSync=V;exports.md5=Ar;exports.md5Adapter=ye;exports.md5Async=xr;exports.md5Core=l;exports.md5Original=l;exports.metrics=he;exports.pipeThroughMD5=E;exports.robustHash=pe;exports.verifyFile=Q
|
|
4
|
-
//# sourceMappingURL=index.cjs.map
|
|
3
|
+
`)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new U;async function W(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let n;try{n=D__default.default.statSync(i);}catch(t){throw new Error(`Failed to access file ${i}: ${t.message}`)}if(!n.isFile())throw new Error(`Path is not a file: ${i}`);let r=D__default.default.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await T(r,{onProgress:e.onProgress,totalSize:n.size})}finally{r.destroy();}}async function T(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let n=R(),r=0;return e.onProgress&&i.on("data",t=>{r+=t.length,e.onProgress?.(r);}),i.on("error",t=>{n.destroy(t);}),i.on("end",()=>{n.end();}),new Promise((t,s)=>{n.on("md5",a=>{t(a);}).on("error",a=>{s(a);}),i.pipe(n);})}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e={}){return (await T(i,e)).digest}async function Q(i,e,n={}){return (await W(i,n)).digest.toLowerCase()===e.toLowerCase()}function V(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D__default.default.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let n;try{n=D__default.default.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return q(n)}function X(i,e){let n=0;return r=>{if(i>0){let t=Math.min(100,r/i*100);Math.floor(t)!==Math.floor(n)&&(e(t),n=t);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await x();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await x()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:n=>l(n),hashBinary:async n=>l(n instanceof Uint8Array?new TextDecoder().decode(n):new TextDecoder().decode(new Uint8Array(n))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await x(),n=F(e);return this.backend=await this.createBackendByName(n),this.backendName=n,this.backend}};function Ar(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}exports.BackendDetector=M;exports.FallbackManager=P;exports.IE11Backend=B;exports.MD5Stream=p;exports.MetricsCollector=U;exports.NodeCryptoBackend=w;exports.PureJSBackend=k;exports.WebCryptoBackend=g;exports.createMD5Stream=R;exports.createProgressTracker=X;exports.detector=le;exports.fallbackManager=be;exports.fromStream=j;exports.getAllAvailableBackends=x;exports.getBestAvailableBackend=F;exports.hashFile=W;exports.hashFileDigest=J;exports.hashFileStream=T;exports.hashFileStreamDigest=Y;exports.hashFileSync=V;exports.md5=Ar;exports.md5Adapter=ye;exports.md5Async=xr;exports.md5Core=l;exports.md5Original=l;exports.metrics=he;exports.pipeThroughMD5=E;exports.robustHash=pe;exports.verifyFile=Q;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
export { md5 as md5Core, md5 as md5Original } from './core/index.js';
|
|
2
1
|
export { WebCryptoBackend } from './adapters/webcrypto.js';
|
|
3
2
|
export { NodeCryptoBackend } from './adapters/node.js';
|
|
4
3
|
export { IE11Backend } from './adapters/ie11.js';
|
|
5
4
|
import { M as MD5Backend } from './types-edGoGJ5V.js';
|
|
6
|
-
|
|
7
|
-
export {
|
|
5
|
+
import { MD5Result } from './stream/md5-stream.js';
|
|
6
|
+
export { MD5Stream, createMD5Stream, fromStream, pipeThroughMD5 } from './stream/md5-stream.js';
|
|
7
|
+
import { Readable } from 'stream';
|
|
8
8
|
export { BackendDetector, FallbackManager, MetricsCollector, detector, fallbackManager, getAllAvailableBackends, getBestAvailableBackend, metrics, robustHash } from './utils/detect.js';
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Core MD5 implementation - Pure JavaScript
|
|
12
|
+
* No dependencies, no environment detection
|
|
13
|
+
* This is the minimal, tree-shakeable core
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Compute MD5 hash of a string
|
|
17
|
+
* @param string - Input string to hash
|
|
18
|
+
* @returns MD5 hash as hex string
|
|
19
|
+
*/
|
|
20
|
+
declare function md5Core(string: string): string;
|
|
10
21
|
|
|
11
22
|
/**
|
|
12
23
|
* Pure JavaScript Backend
|
|
@@ -27,6 +38,139 @@ declare class PureJSBackend implements MD5Backend {
|
|
|
27
38
|
private hexToBuffer;
|
|
28
39
|
}
|
|
29
40
|
|
|
41
|
+
/**
|
|
42
|
+
* File System Utilities for MD5 hashing
|
|
43
|
+
* Provides convenient utilities for hashing files through Node.js file system streams
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Options for file hashing operations
|
|
48
|
+
*/
|
|
49
|
+
interface HashFileOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Chunk size for reading file (default: 64KB)
|
|
52
|
+
*/
|
|
53
|
+
chunkSize?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Progress callback for tracking hashing progress
|
|
56
|
+
* @param current - Current position in bytes
|
|
57
|
+
*/
|
|
58
|
+
onProgress?: (current: number) => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Hash a file by its path
|
|
62
|
+
* @param filePath - Path to the file to hash
|
|
63
|
+
* @param options - Optional configuration
|
|
64
|
+
* @returns Promise with MD5 result (digest and bytes processed)
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { hashFile } from 'pure-md5';
|
|
69
|
+
*
|
|
70
|
+
* const result = await hashFile('path/to/file.txt');
|
|
71
|
+
* console.log('MD5:', result.digest);
|
|
72
|
+
* console.log('Bytes:', result.bytesProcessed);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function hashFile(filePath: string, options?: HashFileOptions): Promise<MD5Result>;
|
|
76
|
+
/**
|
|
77
|
+
* Hash data from an existing readable stream
|
|
78
|
+
* @param readStream - Readable stream to hash
|
|
79
|
+
* @param options - Optional configuration
|
|
80
|
+
* @returns Promise with MD5 result (digest and bytes processed)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { createReadStream } from 'fs';
|
|
85
|
+
* import { hashFileStream } from 'pure-md5';
|
|
86
|
+
*
|
|
87
|
+
* const stream = createReadStream('path/to/file.txt');
|
|
88
|
+
* const result = await hashFileStream(stream);
|
|
89
|
+
* console.log('MD5:', result.digest);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function hashFileStream(readStream: Readable, options?: {
|
|
93
|
+
onProgress?: (current: number) => void;
|
|
94
|
+
totalSize?: number;
|
|
95
|
+
}): Promise<MD5Result>;
|
|
96
|
+
/**
|
|
97
|
+
* Hash a file and return only the hex digest
|
|
98
|
+
* @param filePath - Path to the file to hash
|
|
99
|
+
* @param options - Optional configuration
|
|
100
|
+
* @returns Promise with MD5 hex digest string
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { hashFileDigest } from 'pure-md5';
|
|
105
|
+
*
|
|
106
|
+
* const digest = await hashFileDigest('path/to/file.txt');
|
|
107
|
+
* console.log('MD5:', digest);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare function hashFileDigest(filePath: string, options?: HashFileOptions): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Hash a file stream and return only the hex digest
|
|
113
|
+
* @param readStream - Readable stream to hash
|
|
114
|
+
* @param options - Optional configuration
|
|
115
|
+
* @returns Promise with MD5 hex digest string
|
|
116
|
+
*/
|
|
117
|
+
declare function hashFileStreamDigest(readStream: Readable, options?: {
|
|
118
|
+
onProgress?: (current: number) => void;
|
|
119
|
+
totalSize?: number;
|
|
120
|
+
}): Promise<string>;
|
|
121
|
+
/**
|
|
122
|
+
* Verify file integrity by comparing MD5 hash
|
|
123
|
+
* @param filePath - Path to the file to verify
|
|
124
|
+
* @param expectedDigest - Expected MD5 hex digest
|
|
125
|
+
* @param options - Optional configuration
|
|
126
|
+
* @returns Promise with verification result
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { verifyFile } from 'pure-md5';
|
|
131
|
+
*
|
|
132
|
+
* const isVerified = await verifyFile(
|
|
133
|
+
* 'path/to/file.txt',
|
|
134
|
+
* '5d41402abc4b2a76b9719d911017c592'
|
|
135
|
+
* );
|
|
136
|
+
* console.log('Verified:', isVerified);
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function verifyFile(filePath: string, expectedDigest: string, options?: HashFileOptions): Promise<boolean>;
|
|
140
|
+
/**
|
|
141
|
+
* Get MD5 hash of a file synchronously (not recommended for large files)
|
|
142
|
+
* @param filePath - Path to the file to hash
|
|
143
|
+
* @returns MD5 hex digest string
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* import { hashFileSync } from 'pure-md5';
|
|
148
|
+
*
|
|
149
|
+
* const digest = hashFileSync('path/to/file.txt');
|
|
150
|
+
* console.log('MD5:', digest);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function hashFileSync(filePath: string): string;
|
|
154
|
+
/**
|
|
155
|
+
* Utility to create a progress tracker for file hashing
|
|
156
|
+
* @param totalSize - Total size of the file being hashed
|
|
157
|
+
* @param onUpdate - Callback with progress percentage (0-100)
|
|
158
|
+
* @returns Progress callback function
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* import { hashFile, createProgressTracker } from 'pure-md5';
|
|
163
|
+
*
|
|
164
|
+
* const totalSize = 1024 * 1024 * 100; // 100MB
|
|
165
|
+
* const progress = createProgressTracker(totalSize, (percent) => {
|
|
166
|
+
* console.log(`Progress: ${percent.toFixed(1)}%`);
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* const result = await hashFile('large-file.bin', { onProgress: progress });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function createProgressTracker(totalSize: number, onUpdate: (percentage: number) => void): (current: number) => void;
|
|
173
|
+
|
|
30
174
|
/**
|
|
31
175
|
* Pure MD5 - Unified adapter with auto-detection
|
|
32
176
|
* Supports multiple backends: Web Crypto, Node.js crypto, IE11, and Pure JS
|
|
@@ -81,4 +225,4 @@ declare function md5(data: string): string;
|
|
|
81
225
|
declare const md5Adapter: MD5Adapter;
|
|
82
226
|
declare function md5Async(data: string): Promise<string>;
|
|
83
227
|
|
|
84
|
-
export { MD5Backend, PureJSBackend, md5, md5Adapter, md5Async };
|
|
228
|
+
export { type HashFileOptions, MD5Backend, MD5Result, PureJSBackend, createProgressTracker, hashFile, hashFileDigest, hashFileStream, hashFileStreamDigest, hashFileSync, md5, md5Adapter, md5Async, md5Core, md5Core as md5Original, verifyFile };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {h,j}from'./chunk-6P2QV5SR.js';export{k as BackendDetector,m as FallbackManager,p as MetricsCollector,a as PureJSBackend,l as detector,n as fallbackManager,h as getAllAvailableBackends,j as getBestAvailableBackend,q as metrics,o as robustHash}from'./chunk-6P2QV5SR.js';import {a as a$2}from'./chunk-VFOAY6XI.js';export{a as IE11Backend}from'./chunk-VFOAY6XI.js';import {a as a$4}from'./chunk-PNZTVQA7.js';export{a as NodeCryptoBackend}from'./chunk-PNZTVQA7.js';import {a as a$3}from'./chunk-G5WHEAIQ.js';export{a as WebCryptoBackend}from'./chunk-G5WHEAIQ.js';import {a as a$1}from'./chunk-4KSCMS4Q.js';import'./chunk-PHZ7FTYF.js';import'./chunk-XB5BQIEX.js';export{g as createProgressTracker,a as hashFile,c as hashFileDigest,b as hashFileStream,d as hashFileStreamDigest,f as hashFileSync,e as verifyFile}from'./chunk-H2K353LR.js';import {a}from'./chunk-NWQ4N5RX.js';export{a as md5Core,a as md5Original}from'./chunk-NWQ4N5RX.js';export{a as MD5Stream,b as createMD5Stream,d as fromStream,c as pipeThroughMD5}from'./chunk-JKVD5LHZ.js';import'./chunk-R4JB5MBR.js';import'./chunk-2YXXFGBV.js';var d=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await h();this.backendName=j(e);}return this.backendName}static async getAvailableBackends(){return await h()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new a$4;case "webcrypto":return new a$3;case "ie11":return new a$2;case "stream":return new a$1;default:return {hash:a$1=>a(a$1),hashBinary:async a$1=>a(a$1 instanceof Uint8Array?new TextDecoder().decode(a$1):new TextDecoder().decode(new Uint8Array(a$1))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await h(),a=j(e);return this.backend=await this.createBackendByName(a),this.backendName=a,this.backend}};function I(n){return a(n)}var S=new d;async function O(n){return S.hash(n)}export{I as md5,S as md5Adapter,O as md5Async};//# sourceMappingURL=index.js.map
|
|
2
|
-
|
|
1
|
+
import {Transform}from'stream';import D from'fs';var N=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Z="0123456789abcdef".split(""),O=Z;function ee(i){let e="";for(let n=0;n<4;n++)e+=O[i>>n*8+4&15]+O[i>>n*8&15];return e}function re(i){let e=i.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=ee(i[r]);return n.join("")}var S=re;function te(i,e){return i+e&4294967295}var b=te;function ne(i,e,n,r,t){let s=t||b;return e=s(s(e,i),s(n,r)),e}function se(i,e,n,r){var s=(r||b)(i<<e|i>>>32-e,n);return s}function C(i,e,n,r,t,s,a){return e=ne(i,e,r,s,a),se(e,t,n,a)}function I(i,e,n,r,t,s,a,o){return C(n&r|~n&t,e,n,s,a,o,i)}function L(i,e,n,r,t,s,a,o){return C(n&t|r&~t,e,n,s,a,o,i)}function $(i,e,n,r,t,s,a,o){return C(n^r^t,e,n,s,a,o,i)}function _(i,e,n,r,t,s,a,o){return C(r^(n|~t),e,n,s,a,o,i)}function ie(i,e,n){typeof n>"u"&&(n=b);let r=i[0],t=i[1],s=i[2],a=i[3],o=I.bind(null,n);r=o(r,t,s,a,e[0],7,-680876936),a=o(a,r,t,s,e[1],12,-389564586),s=o(s,a,r,t,e[2],17,606105819),t=o(t,s,a,r,e[3],22,-1044525330),r=o(r,t,s,a,e[4],7,-176418897),a=o(a,r,t,s,e[5],12,1200080426),s=o(s,a,r,t,e[6],17,-1473231341),t=o(t,s,a,r,e[7],22,-45705983),r=o(r,t,s,a,e[8],7,1770035416),a=o(a,r,t,s,e[9],12,-1958414417),s=o(s,a,r,t,e[10],17,-42063),t=o(t,s,a,r,e[11],22,-1990404162),r=o(r,t,s,a,e[12],7,1804603682),a=o(a,r,t,s,e[13],12,-40341101),s=o(s,a,r,t,e[14],17,-1502002290),t=o(t,s,a,r,e[15],22,1236535329);let c=L.bind(null,n);r=c(r,t,s,a,e[1],5,-165796510),a=c(a,r,t,s,e[6],9,-1069501632),s=c(s,a,r,t,e[11],14,643717713),t=c(t,s,a,r,e[0],20,-373897302),r=c(r,t,s,a,e[5],5,-701558691),a=c(a,r,t,s,e[10],9,38016083),s=c(s,a,r,t,e[15],14,-660478335),t=c(t,s,a,r,e[4],20,-405537848),r=c(r,t,s,a,e[9],5,568446438),a=c(a,r,t,s,e[14],9,-1019803690),s=c(s,a,r,t,e[3],14,-187363961),t=c(t,s,a,r,e[8],20,1163531501),r=c(r,t,s,a,e[13],5,-1444681467),a=c(a,r,t,s,e[2],9,-51403784),s=c(s,a,r,t,e[7],14,1735328473),t=c(t,s,a,r,e[12],20,-1926607734);let u=$.bind(null,n);r=u(r,t,s,a,e[5],4,-378558),a=u(a,r,t,s,e[8],11,-2022574463),s=u(s,a,r,t,e[11],16,1839030562),t=u(t,s,a,r,e[14],23,-35309556),r=u(r,t,s,a,e[1],4,-1530992060),a=u(a,r,t,s,e[4],11,1272893353),s=u(s,a,r,t,e[7],16,-155497632),t=u(t,s,a,r,e[10],23,-1094730640),r=u(r,t,s,a,e[13],4,681279174),a=u(a,r,t,s,e[0],11,-358537222),s=u(s,a,r,t,e[3],16,-722521979),t=u(t,s,a,r,e[6],23,76029189),r=u(r,t,s,a,e[9],4,-640364487),a=u(a,r,t,s,e[12],11,-421815835),s=u(s,a,r,t,e[15],16,530742520),t=u(t,s,a,r,e[2],23,-995338651);let f=_.bind(null,n);r=f(r,t,s,a,e[0],6,-198630844),a=f(a,r,t,s,e[7],10,1126891415),s=f(s,a,r,t,e[14],15,-1416354905),t=f(t,s,a,r,e[5],21,-57434055),r=f(r,t,s,a,e[12],6,1700485571),a=f(a,r,t,s,e[3],10,-1894986606),s=f(s,a,r,t,e[10],15,-1051523),t=f(t,s,a,r,e[1],21,-2054922799),r=f(r,t,s,a,e[8],6,1873313359),a=f(a,r,t,s,e[15],10,-30611744),s=f(s,a,r,t,e[6],15,-1560198380),t=f(t,s,a,r,e[13],21,1309151649),r=f(r,t,s,a,e[4],6,-145523070),a=f(a,r,t,s,e[11],10,-1120210379),s=f(s,a,r,t,e[2],15,718787259),t=f(t,s,a,r,e[9],21,-343485551),i[0]=n(r,i[0]),i[1]=n(t,i[1]),i[2]=n(s,i[2]),i[3]=n(a,i[3]);}var m=ie;function ae(i){let e=[];for(let n=0;n<64;n+=4)e[n>>2]=(i.charCodeAt(n)||0)+((i.charCodeAt(n+1)||0)<<8)+((i.charCodeAt(n+2)||0)<<16)+((i.charCodeAt(n+3)||0)<<24);return e}var G=ae;function oe(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64)m(r,G(i.substring(t-64,t)),e);i=i.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a=i.length;for(t=0;t<a;t++)s[t>>2]|=(i.charCodeAt(t)&255)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(m(r,s,e),t=16;t--;)s[t]=0;return s[14]=n*8,m(r,s,e),r}var z=oe;function ce(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64){let o=ue(i,t-64);m(r,o,e);}let s=n-t+64,a=new Array(16).fill(0);for(let o=0;o<s;o++)a[o>>2]|=(i[n-s+o]&255)<<(o%4<<3);if(a[s>>2]|=128<<(s%4<<3),s>55){m(r,a,e);for(let o=0;o<16;o++)a[o]=0;}return a[14]=n*8,a[15]=0,m(r,a,e),r}function ue(i,e){let n=[];for(let r=0;r<64;r+=4)n[r>>2]=(i[e+r]||0)+((i[e+r+1]||0)<<8)+((i[e+r+2]||0)<<16)+((i[e+r+3]||0)<<24);return n}var K=ce;function l(i){return S(z(i,b))}function q(i){return S(K(i,b))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof N("crypto").createHash=="function"}catch{return false}}hash(e){return N("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let n=N("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return n.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var B=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let n=window,r=e instanceof Uint8Array?e.buffer:e,t=await n.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(t)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var p=class i extends Transform{constructor(n){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=n?.add32||b,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(n,r,t){try{let s=n,a=s.length;if(a===0){t();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,h=Math.min(a,f);for(let d=0;d<h;d++)this.buffer[u+d]=s[d];if(this.state.bufferLength+=h,this.state.bufferLength===64&&this._processBufferBlock(),h===a){t();return}let y=a-h;for(let d=0;d<y;d++)s[d]=s[h+d];let v=Buffer.alloc(y);for(let d=0;d<y;d++)v[d]=s[d];s=v;}let o=Math.floor(s.length/64);for(let u=0;u<o;u++){let f=u*64,h=[];for(let y=0;y<16;y++){let v=f+y*4;h[y]=s[v]+(s[v+1]<<8)+(s[v+2]<<16)+(s[v+3]<<24);}m(this.state.state,h,this.add32),this.state.bytesProcessed+=64;}let c=s.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let u=0;u<c;u++)this.buffer[u]=s[o*64+u];this.state.bufferLength=c;}t();}catch(s){t(s);}}_processBufferBlock(){let n=this.state.buffer,r=[];for(let t=0;t<16;t++){let s=t*4;r[t]=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+(n[s+3]<<24);}m(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(n){try{let{state:r,bufferLength:t,buffer:s}=this.state,a=new Array(16).fill(0);for(let c=0;c<t;c++)a[c>>2]|=(s[c]&255)<<(c%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55){m(r,a,this.add32);for(let c=0;c<16;c++)a[c]=0;}a[14]=(this.state.bytesProcessed+t)*8,a[15]=0,m(r,a,this.add32);let o=S(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+t}),n();}catch(r){n(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(n,r){let t=new i(r),s=E.call(t,n);return {stream:t,result:s}}};function R(i){return new p(i)}async function E(i){return new Promise((e,n)=>{let r=[];i.pipe(this).on("md5",t=>{r.push(t);}).on("error",n).on("finish",()=>{e(r[0]);});})}function j(i,e){let n=new p(e),r=E.call(n,i);return {stream:n,result:r}}var A=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let n=new p;return (await new Promise((t,s)=>{n.on("md5",a=>t(a)).on("error",s).end(e);})).digest}async hashBinary(e){let n=new p,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((s,a)=>{n.on("md5",o=>s(o)).on("error",a).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),n.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream;return n.end(),new Promise((r,t)=>{n.on("md5",s=>{if(e==="buffer"){let a=s.digest,o=[];for(let c=0;c<a.length;c+=2)o.push(parseInt(a.substring(c,c+2),16));r(Buffer.from(o));}else r(s.digest);}).on("error",t);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var k=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let n=l(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(n):n}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let n=[];for(let r=0;r<e.length;r+=2)n.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(n)}};async function de(i){switch(i){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let n=w.isAvailable();return {backend:"nodecrypto",available:n,reason:n?void 0:"Node.js crypto not available"};case "ie11":let r=B.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let t=typeof process<"u"&&process.versions&&"node"in process.versions,s=typeof window<"u";return {backend:"stream",available:t||s,reason:t||s?void 0:"Streams not available"};default:return {backend:i||"unknown",available:false,reason:"Unknown backend"}}}async function x(){let i=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let n of i){let{available:r}=await de(n);r&&e.push(n);}return e}var me=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function F(i){let e=[...me].sort((n,r)=>n.priority-r.priority);for(let{name:n}of e)if(i.includes(n))return n;return "purejs"}var M=class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return new k}}async createBackend(e){let n=e||F(await x());return this.createBackendByName(n)}},le=M.getInstance(),P=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let n=[];for(let r of this.fallbackOrder)try{let t=await this.detector.createBackendByName(r),s=await e(t);return {success:!0,backend:r,data:s}}catch(t){if(n.push({backend:r,error:t}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:n}}return {success:false,backend:"",data:null,errors:n}}async hash(e){return this.execute(async n=>n.hash(e))}async hashBinary(e){return this.execute(async n=>n.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let n of this.fallbackOrder)try{await this.detector.createBackendByName(n),e.push(n);}catch{}return e}getMetrics(){return {}}},be=new P;async function pe(i,e={}){let n=new P;if(e.forceBackend)return (await n.detector.createBackendByName(e.forceBackend)).hash(i);if(e.fallback===false)return (await n.detector.createBackend()).hash(i);let r=await n.hash(i);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let t=r.errors?r.errors.map(s=>`${s.backend}: ${s.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${t}`)}var U=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((n,r)=>n+r.success+r.fail,0)}
|
|
2
|
+
`+Object.entries(this.metrics).map(([,n])=>`${n.success} success, ${n.fail} fail`).join(`
|
|
3
|
+
`)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new U;async function W(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D.existsSync(i))throw new Error(`File not found: ${i}`);let n;try{n=D.statSync(i);}catch(t){throw new Error(`Failed to access file ${i}: ${t.message}`)}if(!n.isFile())throw new Error(`Path is not a file: ${i}`);let r=D.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await T(r,{onProgress:e.onProgress,totalSize:n.size})}finally{r.destroy();}}async function T(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let n=R(),r=0;return e.onProgress&&i.on("data",t=>{r+=t.length,e.onProgress?.(r);}),i.on("error",t=>{n.destroy(t);}),i.on("end",()=>{n.end();}),new Promise((t,s)=>{n.on("md5",a=>{t(a);}).on("error",a=>{s(a);}),i.pipe(n);})}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e={}){return (await T(i,e)).digest}async function Q(i,e,n={}){return (await W(i,n)).digest.toLowerCase()===e.toLowerCase()}function V(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let n;try{n=D.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return q(n)}function X(i,e){let n=0;return r=>{if(i>0){let t=Math.min(100,r/i*100);Math.floor(t)!==Math.floor(n)&&(e(t),n=t);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await x();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await x()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:n=>l(n),hashBinary:async n=>l(n instanceof Uint8Array?new TextDecoder().decode(n):new TextDecoder().decode(new Uint8Array(n))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await x(),n=F(e);return this.backend=await this.createBackendByName(n),this.backendName=n,this.backend}};function Ar(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}export{M as BackendDetector,P as FallbackManager,B as IE11Backend,p as MD5Stream,U as MetricsCollector,w as NodeCryptoBackend,k as PureJSBackend,g as WebCryptoBackend,R as createMD5Stream,X as createProgressTracker,le as detector,be as fallbackManager,j as fromStream,x as getAllAvailableBackends,F as getBestAvailableBackend,W as hashFile,J as hashFileDigest,T as hashFileStream,Y as hashFileStreamDigest,V as hashFileSync,Ar as md5,ye as md5Adapter,xr as md5Async,l as md5Core,l as md5Original,he as metrics,E as pipeThroughMD5,pe as robustHash,Q as verifyFile};
|
package/dist/md5.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var C="0123456789abcdef".split(""),h=C;function v(m){let u="";for(let o=0;o<4;o++)u+=h[m>>o*8+4&15]+h[m>>o*8&15];return u}function j(m){let u=m.length,o=new Array(u);for(let r=0;r<u;r++)o[r]=v(m[r]);return o.join("")}var s=j;function w(m,u){return m+u&4294967295}var f=w;function _(m,u,o,r,n){let e=n||f;return u=e(e(u,m),e(o,r)),u}function q(m,u,o,r){var e=(r||f)(m<<u|m>>>32-u,o);return e}function l(m,u,o,r,n,e,t){return u=_(m,u,r,e,t),q(u,n,o,t)}function g(m,u,o,r,n,e,t,b){return l(o&r|~o&n,u,o,e,t,b,m)}function a(m,u,o,r,n,e,t,b){return l(o&n|r&~n,u,o,e,t,b,m)}function A(m,u,o,r,n,e,t,b){return l(o^r^n,u,o,e,t,b,m)}function x(m,u,o,r,n,e,t,b){return l(r^(o|~n),u,o,e,t,b,m)}function z(m,u,o){typeof o>"u"&&(o=f);let r=m[0],n=m[1],e=m[2],t=m[3],b=g.bind(null,o);r=b(r,n,e,t,u[0],7,-680876936),t=b(t,r,n,e,u[1],12,-389564586),e=b(e,t,r,n,u[2],17,606105819),n=b(n,e,t,r,u[3],22,-1044525330),r=b(r,n,e,t,u[4],7,-176418897),t=b(t,r,n,e,u[5],12,1200080426),e=b(e,t,r,n,u[6],17,-1473231341),n=b(n,e,t,r,u[7],22,-45705983),r=b(r,n,e,t,u[8],7,1770035416),t=b(t,r,n,e,u[9],12,-1958414417),e=b(e,t,r,n,u[10],17,-42063),n=b(n,e,t,r,u[11],22,-1990404162),r=b(r,n,e,t,u[12],7,1804603682),t=b(t,r,n,e,u[13],12,-40341101),e=b(e,t,r,n,u[14],17,-1502002290),n=b(n,e,t,r,u[15],22,1236535329);let i=a.bind(null,o);r=i(r,n,e,t,u[1],5,-165796510),t=i(t,r,n,e,u[6],9,-1069501632),e=i(e,t,r,n,u[11],14,643717713),n=i(n,e,t,r,u[0],20,-373897302),r=i(r,n,e,t,u[5],5,-701558691),t=i(t,r,n,e,u[10],9,38016083),e=i(e,t,r,n,u[15],14,-660478335),n=i(n,e,t,r,u[4],20,-405537848),r=i(r,n,e,t,u[9],5,568446438),t=i(t,r,n,e,u[14],9,-1019803690),e=i(e,t,r,n,u[3],14,-187363961),n=i(n,e,t,r,u[8],20,1163531501),r=i(r,n,e,t,u[13],5,-1444681467),t=i(t,r,n,e,u[2],9,-51403784),e=i(e,t,r,n,u[7],14,1735328473),n=i(n,e,t,r,u[12],20,-1926607734);let d=A.bind(null,o);r=d(r,n,e,t,u[5],4,-378558),t=d(t,r,n,e,u[8],11,-2022574463),e=d(e,t,r,n,u[11],16,1839030562),n=d(n,e,t,r,u[14],23,-35309556),r=d(r,n,e,t,u[1],4,-1530992060),t=d(t,r,n,e,u[4],11,1272893353),e=d(e,t,r,n,u[7],16,-155497632),n=d(n,e,t,r,u[10],23,-1094730640),r=d(r,n,e,t,u[13],4,681279174),t=d(t,r,n,e,u[0],11,-358537222),e=d(e,t,r,n,u[3],16,-722521979),n=d(n,e,t,r,u[6],23,76029189),r=d(r,n,e,t,u[9],4,-640364487),t=d(t,r,n,e,u[12],11,-421815835),e=d(e,t,r,n,u[15],16,530742520),n=d(n,e,t,r,u[2],23,-995338651);let c=x.bind(null,o);r=c(r,n,e,t,u[0],6,-198630844),t=c(t,r,n,e,u[7],10,1126891415),e=c(e,t,r,n,u[14],15,-1416354905),n=c(n,e,t,r,u[5],21,-57434055),r=c(r,n,e,t,u[12],6,1700485571),t=c(t,r,n,e,u[3],10,-1894986606),e=c(e,t,r,n,u[10],15,-1051523),n=c(n,e,t,r,u[1],21,-2054922799),r=c(r,n,e,t,u[8],6,1873313359),t=c(t,r,n,e,u[15],10,-30611744),e=c(e,t,r,n,u[6],15,-1560198380),n=c(n,e,t,r,u[13],21,1309151649),r=c(r,n,e,t,u[4],6,-145523070),t=c(t,r,n,e,u[11],10,-1120210379),e=c(e,t,r,n,u[2],15,718787259),n=c(n,e,t,r,u[9],21,-343485551),m[0]=o(r,m[0]),m[1]=o(n,m[1]),m[2]=o(e,m[2]),m[3]=o(t,m[3]);}var p=z;function B(m){let u=[];for(let o=0;o<64;o+=4)u[o>>2]=(m.charCodeAt(o)||0)+((m.charCodeAt(o+1)||0)<<8)+((m.charCodeAt(o+2)||0)<<16)+((m.charCodeAt(o+3)||0)<<24);return u}var F=B;function D(m,u){let o=m.length,r=[1732584193,-271733879,-1732584194,271733878],n;for(n=64;n<=o;n+=64)p(r,F(m.substring(n-64,n)),u);m=m.substring(n-64);var e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=m.length;for(n=0;n<t;n++)e[n>>2]|=(m.charCodeAt(n)&255)<<(n%4<<3);if(e[n>>2]|=128<<(n%4<<3),n>55)for(p(r,e,u),n=16;n--;)e[n]=0;return e[14]=o*8,p(r,e,u),r}var y=D;function V(m){return s(y(m,f))}exports.md5=V;
|
package/dist/md5.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure MD5 - Minimal entry point for basic MD5 hashing
|
|
3
|
+
* Only includes the md5() function with zero dependencies
|
|
4
|
+
* Perfect for tree-shaking - will only bundle what's needed
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Compute MD5 hash of a string
|
|
8
|
+
* @param data - Input string to hash
|
|
9
|
+
* @returns MD5 hash as hex string (32 characters)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { md5 } from 'pure-md5/md5';
|
|
14
|
+
*
|
|
15
|
+
* md5('hello'); // "5d41402abc4b2a76b9719d911017c592"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function md5(data: string): string;
|
|
19
|
+
|
|
20
|
+
export { md5 };
|
package/dist/md5.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C="0123456789abcdef".split(""),h=C;function v(m){let u="";for(let o=0;o<4;o++)u+=h[m>>o*8+4&15]+h[m>>o*8&15];return u}function j(m){let u=m.length,o=new Array(u);for(let r=0;r<u;r++)o[r]=v(m[r]);return o.join("")}var s=j;function w(m,u){return m+u&4294967295}var f=w;function _(m,u,o,r,n){let e=n||f;return u=e(e(u,m),e(o,r)),u}function q(m,u,o,r){var e=(r||f)(m<<u|m>>>32-u,o);return e}function l(m,u,o,r,n,e,t){return u=_(m,u,r,e,t),q(u,n,o,t)}function g(m,u,o,r,n,e,t,b){return l(o&r|~o&n,u,o,e,t,b,m)}function a(m,u,o,r,n,e,t,b){return l(o&n|r&~n,u,o,e,t,b,m)}function A(m,u,o,r,n,e,t,b){return l(o^r^n,u,o,e,t,b,m)}function x(m,u,o,r,n,e,t,b){return l(r^(o|~n),u,o,e,t,b,m)}function z(m,u,o){typeof o>"u"&&(o=f);let r=m[0],n=m[1],e=m[2],t=m[3],b=g.bind(null,o);r=b(r,n,e,t,u[0],7,-680876936),t=b(t,r,n,e,u[1],12,-389564586),e=b(e,t,r,n,u[2],17,606105819),n=b(n,e,t,r,u[3],22,-1044525330),r=b(r,n,e,t,u[4],7,-176418897),t=b(t,r,n,e,u[5],12,1200080426),e=b(e,t,r,n,u[6],17,-1473231341),n=b(n,e,t,r,u[7],22,-45705983),r=b(r,n,e,t,u[8],7,1770035416),t=b(t,r,n,e,u[9],12,-1958414417),e=b(e,t,r,n,u[10],17,-42063),n=b(n,e,t,r,u[11],22,-1990404162),r=b(r,n,e,t,u[12],7,1804603682),t=b(t,r,n,e,u[13],12,-40341101),e=b(e,t,r,n,u[14],17,-1502002290),n=b(n,e,t,r,u[15],22,1236535329);let i=a.bind(null,o);r=i(r,n,e,t,u[1],5,-165796510),t=i(t,r,n,e,u[6],9,-1069501632),e=i(e,t,r,n,u[11],14,643717713),n=i(n,e,t,r,u[0],20,-373897302),r=i(r,n,e,t,u[5],5,-701558691),t=i(t,r,n,e,u[10],9,38016083),e=i(e,t,r,n,u[15],14,-660478335),n=i(n,e,t,r,u[4],20,-405537848),r=i(r,n,e,t,u[9],5,568446438),t=i(t,r,n,e,u[14],9,-1019803690),e=i(e,t,r,n,u[3],14,-187363961),n=i(n,e,t,r,u[8],20,1163531501),r=i(r,n,e,t,u[13],5,-1444681467),t=i(t,r,n,e,u[2],9,-51403784),e=i(e,t,r,n,u[7],14,1735328473),n=i(n,e,t,r,u[12],20,-1926607734);let d=A.bind(null,o);r=d(r,n,e,t,u[5],4,-378558),t=d(t,r,n,e,u[8],11,-2022574463),e=d(e,t,r,n,u[11],16,1839030562),n=d(n,e,t,r,u[14],23,-35309556),r=d(r,n,e,t,u[1],4,-1530992060),t=d(t,r,n,e,u[4],11,1272893353),e=d(e,t,r,n,u[7],16,-155497632),n=d(n,e,t,r,u[10],23,-1094730640),r=d(r,n,e,t,u[13],4,681279174),t=d(t,r,n,e,u[0],11,-358537222),e=d(e,t,r,n,u[3],16,-722521979),n=d(n,e,t,r,u[6],23,76029189),r=d(r,n,e,t,u[9],4,-640364487),t=d(t,r,n,e,u[12],11,-421815835),e=d(e,t,r,n,u[15],16,530742520),n=d(n,e,t,r,u[2],23,-995338651);let c=x.bind(null,o);r=c(r,n,e,t,u[0],6,-198630844),t=c(t,r,n,e,u[7],10,1126891415),e=c(e,t,r,n,u[14],15,-1416354905),n=c(n,e,t,r,u[5],21,-57434055),r=c(r,n,e,t,u[12],6,1700485571),t=c(t,r,n,e,u[3],10,-1894986606),e=c(e,t,r,n,u[10],15,-1051523),n=c(n,e,t,r,u[1],21,-2054922799),r=c(r,n,e,t,u[8],6,1873313359),t=c(t,r,n,e,u[15],10,-30611744),e=c(e,t,r,n,u[6],15,-1560198380),n=c(n,e,t,r,u[13],21,1309151649),r=c(r,n,e,t,u[4],6,-145523070),t=c(t,r,n,e,u[11],10,-1120210379),e=c(e,t,r,n,u[2],15,718787259),n=c(n,e,t,r,u[9],21,-343485551),m[0]=o(r,m[0]),m[1]=o(n,m[1]),m[2]=o(e,m[2]),m[3]=o(t,m[3]);}var p=z;function B(m){let u=[];for(let o=0;o<64;o+=4)u[o>>2]=(m.charCodeAt(o)||0)+((m.charCodeAt(o+1)||0)<<8)+((m.charCodeAt(o+2)||0)<<16)+((m.charCodeAt(o+3)||0)<<24);return u}var F=B;function D(m,u){let o=m.length,r=[1732584193,-271733879,-1732584194,271733878],n;for(n=64;n<=o;n+=64)p(r,F(m.substring(n-64,n)),u);m=m.substring(n-64);var e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=m.length;for(n=0;n<t;n++)e[n>>2]|=(m.charCodeAt(n)&255)<<(n%4<<3);if(e[n>>2]|=128<<(n%4<<3),n>55)for(p(r,e,u),n=16;n--;)e[n]=0;return e[14]=o*8,p(r,e,u),r}var y=D;function V(m){return s(y(m,f))}export{V as md5};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var stream=require('stream');function B(i,s){return i+s&4294967295}var l=B;function v(i,s,u,t,r){let e=r||l;return s=e(e(s,i),e(u,t)),s}function w(i,s,u,t){var e=(t||l)(i<<s|i>>>32-s,u);return e}function g(i,s,u,t,r,e,n){return s=v(i,s,t,e,n),w(s,r,u,n)}function D(i,s,u,t,r,e,n,f){return g(u&t|~u&r,s,u,e,n,f,i)}function x(i,s,u,t,r,e,n,f){return g(u&r|t&~r,s,u,e,n,f,i)}function P(i,s,u,t,r,e,n,f){return g(u^t^r,s,u,e,n,f,i)}function S(i,s,u,t,r,e,n,f){return g(t^(u|~r),s,u,e,n,f,i)}function F(i,s,u){typeof u>"u"&&(u=l);let t=i[0],r=i[1],e=i[2],n=i[3],f=D.bind(null,u);t=f(t,r,e,n,s[0],7,-680876936),n=f(n,t,r,e,s[1],12,-389564586),e=f(e,n,t,r,s[2],17,606105819),r=f(r,e,n,t,s[3],22,-1044525330),t=f(t,r,e,n,s[4],7,-176418897),n=f(n,t,r,e,s[5],12,1200080426),e=f(e,n,t,r,s[6],17,-1473231341),r=f(r,e,n,t,s[7],22,-45705983),t=f(t,r,e,n,s[8],7,1770035416),n=f(n,t,r,e,s[9],12,-1958414417),e=f(e,n,t,r,s[10],17,-42063),r=f(r,e,n,t,s[11],22,-1990404162),t=f(t,r,e,n,s[12],7,1804603682),n=f(n,t,r,e,s[13],12,-40341101),e=f(e,n,t,r,s[14],17,-1502002290),r=f(r,e,n,t,s[15],22,1236535329);let o=x.bind(null,u);t=o(t,r,e,n,s[1],5,-165796510),n=o(n,t,r,e,s[6],9,-1069501632),e=o(e,n,t,r,s[11],14,643717713),r=o(r,e,n,t,s[0],20,-373897302),t=o(t,r,e,n,s[5],5,-701558691),n=o(n,t,r,e,s[10],9,38016083),e=o(e,n,t,r,s[15],14,-660478335),r=o(r,e,n,t,s[4],20,-405537848),t=o(t,r,e,n,s[9],5,568446438),n=o(n,t,r,e,s[14],9,-1019803690),e=o(e,n,t,r,s[3],14,-187363961),r=o(r,e,n,t,s[8],20,1163531501),t=o(t,r,e,n,s[13],5,-1444681467),n=o(n,t,r,e,s[2],9,-51403784),e=o(e,n,t,r,s[7],14,1735328473),r=o(r,e,n,t,s[12],20,-1926607734);let a=P.bind(null,u);t=a(t,r,e,n,s[5],4,-378558),n=a(n,t,r,e,s[8],11,-2022574463),e=a(e,n,t,r,s[11],16,1839030562),r=a(r,e,n,t,s[14],23,-35309556),t=a(t,r,e,n,s[1],4,-1530992060),n=a(n,t,r,e,s[4],11,1272893353),e=a(e,n,t,r,s[7],16,-155497632),r=a(r,e,n,t,s[10],23,-1094730640),t=a(t,r,e,n,s[13],4,681279174),n=a(n,t,r,e,s[0],11,-358537222),e=a(e,n,t,r,s[3],16,-722521979),r=a(r,e,n,t,s[6],23,76029189),t=a(t,r,e,n,s[9],4,-640364487),n=a(n,t,r,e,s[12],11,-421815835),e=a(e,n,t,r,s[15],16,530742520),r=a(r,e,n,t,s[2],23,-995338651);let b=S.bind(null,u);t=b(t,r,e,n,s[0],6,-198630844),n=b(n,t,r,e,s[7],10,1126891415),e=b(e,n,t,r,s[14],15,-1416354905),r=b(r,e,n,t,s[5],21,-57434055),t=b(t,r,e,n,s[12],6,1700485571),n=b(n,t,r,e,s[3],10,-1894986606),e=b(e,n,t,r,s[10],15,-1051523),r=b(r,e,n,t,s[1],21,-2054922799),t=b(t,r,e,n,s[8],6,1873313359),n=b(n,t,r,e,s[15],10,-30611744),e=b(e,n,t,r,s[6],15,-1560198380),r=b(r,e,n,t,s[13],21,1309151649),t=b(t,r,e,n,s[4],6,-145523070),n=b(n,t,r,e,s[11],10,-1120210379),e=b(e,n,t,r,s[2],15,718787259),r=b(r,e,n,t,s[9],21,-343485551),i[0]=u(t,i[0]),i[1]=u(r,i[1]),i[2]=u(e,i[2]),i[3]=u(n,i[3]);}var p=F;var R="0123456789abcdef".split(""),M=R;function C(i){let s="";for(let u=0;u<4;u++)s+=M[i>>u*8+4&15]+M[i>>u*8&15];return s}function O(i){let s=i.length,u=new Array(s);for(let t=0;t<s;t++)u[t]=C(i[t]);return u.join("")}var A=O;var y=class i extends stream.Transform{constructor(u){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=u?.add32||l,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(u,t,r){try{let e=u,n=e.length;if(n===0){r();return}if(this.state.bufferLength>0){let a=this.state.bufferLength,b=64-a,c=Math.min(n,b);for(let m=0;m<c;m++)this.buffer[a+m]=e[m];if(this.state.bufferLength+=c,this.state.bufferLength===64&&this._processBufferBlock(),c===n){r();return}let d=n-c;for(let m=0;m<d;m++)e[m]=e[c+m];let h=Buffer.alloc(d);for(let m=0;m<d;m++)h[m]=e[m];e=h;}let f=Math.floor(e.length/64);for(let a=0;a<f;a++){let b=a*64,c=[];for(let d=0;d<16;d++){let h=b+d*4;c[d]=e[h]+(e[h+1]<<8)+(e[h+2]<<16)+(e[h+3]<<24);}p(this.state.state,c,this.add32),this.state.bytesProcessed+=64;}let o=e.length%64;if(o>0){this.buffer.length<o&&(this.buffer=new Uint8Array(o),this.state.buffer=this.buffer);for(let a=0;a<o;a++)this.buffer[a]=e[f*64+a];this.state.bufferLength=o;}r();}catch(e){r(e);}}_processBufferBlock(){let u=this.state.buffer,t=[];for(let r=0;r<16;r++){let e=r*4;t[r]=u[e]+(u[e+1]<<8)+(u[e+2]<<16)+(u[e+3]<<24);}p(this.state.state,t,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(u){try{let{state:t,bufferLength:r,buffer:e}=this.state,n=new Array(16).fill(0);for(let o=0;o<r;o++)n[o>>2]|=(e[o]&255)<<(o%4<<3);if(n[r>>2]|=128<<(r%4<<3),r>55){p(t,n,this.add32);for(let o=0;o<16;o++)n[o]=0;}n[14]=(this.state.bytesProcessed+r)*8,n[15]=0,p(t,n,this.add32);let f=A(t);this.emit("md5",{digest:f,bytesProcessed:this.state.bytesProcessed+r}),u();}catch(t){u(t);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(u,t){let r=new i(t),e=L.call(r,u);return {stream:r,result:e}}};function W(i){return new y(i)}async function L(i){return new Promise((s,u)=>{let t=[];i.pipe(this).on("md5",r=>{t.push(r);}).on("error",u).on("finish",()=>{s(t[0]);});})}function X(i,s){let u=new y(s),t=L.call(u,i);return {stream:u,result:t}}exports.MD5Stream=y;exports.createMD5Stream=W;exports.fromStream=X;exports.pipeThroughMD5=L
|
|
2
|
-
//# sourceMappingURL=md5-stream.cjs.map
|
|
1
|
+
'use strict';var stream=require('stream');function B(i,s){return i+s&4294967295}var l=B;function v(i,s,u,t,r){let e=r||l;return s=e(e(s,i),e(u,t)),s}function w(i,s,u,t){var e=(t||l)(i<<s|i>>>32-s,u);return e}function g(i,s,u,t,r,e,n){return s=v(i,s,t,e,n),w(s,r,u,n)}function D(i,s,u,t,r,e,n,f){return g(u&t|~u&r,s,u,e,n,f,i)}function x(i,s,u,t,r,e,n,f){return g(u&r|t&~r,s,u,e,n,f,i)}function P(i,s,u,t,r,e,n,f){return g(u^t^r,s,u,e,n,f,i)}function S(i,s,u,t,r,e,n,f){return g(t^(u|~r),s,u,e,n,f,i)}function F(i,s,u){typeof u>"u"&&(u=l);let t=i[0],r=i[1],e=i[2],n=i[3],f=D.bind(null,u);t=f(t,r,e,n,s[0],7,-680876936),n=f(n,t,r,e,s[1],12,-389564586),e=f(e,n,t,r,s[2],17,606105819),r=f(r,e,n,t,s[3],22,-1044525330),t=f(t,r,e,n,s[4],7,-176418897),n=f(n,t,r,e,s[5],12,1200080426),e=f(e,n,t,r,s[6],17,-1473231341),r=f(r,e,n,t,s[7],22,-45705983),t=f(t,r,e,n,s[8],7,1770035416),n=f(n,t,r,e,s[9],12,-1958414417),e=f(e,n,t,r,s[10],17,-42063),r=f(r,e,n,t,s[11],22,-1990404162),t=f(t,r,e,n,s[12],7,1804603682),n=f(n,t,r,e,s[13],12,-40341101),e=f(e,n,t,r,s[14],17,-1502002290),r=f(r,e,n,t,s[15],22,1236535329);let o=x.bind(null,u);t=o(t,r,e,n,s[1],5,-165796510),n=o(n,t,r,e,s[6],9,-1069501632),e=o(e,n,t,r,s[11],14,643717713),r=o(r,e,n,t,s[0],20,-373897302),t=o(t,r,e,n,s[5],5,-701558691),n=o(n,t,r,e,s[10],9,38016083),e=o(e,n,t,r,s[15],14,-660478335),r=o(r,e,n,t,s[4],20,-405537848),t=o(t,r,e,n,s[9],5,568446438),n=o(n,t,r,e,s[14],9,-1019803690),e=o(e,n,t,r,s[3],14,-187363961),r=o(r,e,n,t,s[8],20,1163531501),t=o(t,r,e,n,s[13],5,-1444681467),n=o(n,t,r,e,s[2],9,-51403784),e=o(e,n,t,r,s[7],14,1735328473),r=o(r,e,n,t,s[12],20,-1926607734);let a=P.bind(null,u);t=a(t,r,e,n,s[5],4,-378558),n=a(n,t,r,e,s[8],11,-2022574463),e=a(e,n,t,r,s[11],16,1839030562),r=a(r,e,n,t,s[14],23,-35309556),t=a(t,r,e,n,s[1],4,-1530992060),n=a(n,t,r,e,s[4],11,1272893353),e=a(e,n,t,r,s[7],16,-155497632),r=a(r,e,n,t,s[10],23,-1094730640),t=a(t,r,e,n,s[13],4,681279174),n=a(n,t,r,e,s[0],11,-358537222),e=a(e,n,t,r,s[3],16,-722521979),r=a(r,e,n,t,s[6],23,76029189),t=a(t,r,e,n,s[9],4,-640364487),n=a(n,t,r,e,s[12],11,-421815835),e=a(e,n,t,r,s[15],16,530742520),r=a(r,e,n,t,s[2],23,-995338651);let b=S.bind(null,u);t=b(t,r,e,n,s[0],6,-198630844),n=b(n,t,r,e,s[7],10,1126891415),e=b(e,n,t,r,s[14],15,-1416354905),r=b(r,e,n,t,s[5],21,-57434055),t=b(t,r,e,n,s[12],6,1700485571),n=b(n,t,r,e,s[3],10,-1894986606),e=b(e,n,t,r,s[10],15,-1051523),r=b(r,e,n,t,s[1],21,-2054922799),t=b(t,r,e,n,s[8],6,1873313359),n=b(n,t,r,e,s[15],10,-30611744),e=b(e,n,t,r,s[6],15,-1560198380),r=b(r,e,n,t,s[13],21,1309151649),t=b(t,r,e,n,s[4],6,-145523070),n=b(n,t,r,e,s[11],10,-1120210379),e=b(e,n,t,r,s[2],15,718787259),r=b(r,e,n,t,s[9],21,-343485551),i[0]=u(t,i[0]),i[1]=u(r,i[1]),i[2]=u(e,i[2]),i[3]=u(n,i[3]);}var p=F;var R="0123456789abcdef".split(""),M=R;function C(i){let s="";for(let u=0;u<4;u++)s+=M[i>>u*8+4&15]+M[i>>u*8&15];return s}function O(i){let s=i.length,u=new Array(s);for(let t=0;t<s;t++)u[t]=C(i[t]);return u.join("")}var A=O;var y=class i extends stream.Transform{constructor(u){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=u?.add32||l,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(u,t,r){try{let e=u,n=e.length;if(n===0){r();return}if(this.state.bufferLength>0){let a=this.state.bufferLength,b=64-a,c=Math.min(n,b);for(let m=0;m<c;m++)this.buffer[a+m]=e[m];if(this.state.bufferLength+=c,this.state.bufferLength===64&&this._processBufferBlock(),c===n){r();return}let d=n-c;for(let m=0;m<d;m++)e[m]=e[c+m];let h=Buffer.alloc(d);for(let m=0;m<d;m++)h[m]=e[m];e=h;}let f=Math.floor(e.length/64);for(let a=0;a<f;a++){let b=a*64,c=[];for(let d=0;d<16;d++){let h=b+d*4;c[d]=e[h]+(e[h+1]<<8)+(e[h+2]<<16)+(e[h+3]<<24);}p(this.state.state,c,this.add32),this.state.bytesProcessed+=64;}let o=e.length%64;if(o>0){this.buffer.length<o&&(this.buffer=new Uint8Array(o),this.state.buffer=this.buffer);for(let a=0;a<o;a++)this.buffer[a]=e[f*64+a];this.state.bufferLength=o;}r();}catch(e){r(e);}}_processBufferBlock(){let u=this.state.buffer,t=[];for(let r=0;r<16;r++){let e=r*4;t[r]=u[e]+(u[e+1]<<8)+(u[e+2]<<16)+(u[e+3]<<24);}p(this.state.state,t,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(u){try{let{state:t,bufferLength:r,buffer:e}=this.state,n=new Array(16).fill(0);for(let o=0;o<r;o++)n[o>>2]|=(e[o]&255)<<(o%4<<3);if(n[r>>2]|=128<<(r%4<<3),r>55){p(t,n,this.add32);for(let o=0;o<16;o++)n[o]=0;}n[14]=(this.state.bytesProcessed+r)*8,n[15]=0,p(t,n,this.add32);let f=A(t);this.emit("md5",{digest:f,bytesProcessed:this.state.bytesProcessed+r}),u();}catch(t){u(t);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(u,t){let r=new i(t),e=L.call(r,u);return {stream:r,result:e}}};function W(i){return new y(i)}async function L(i){return new Promise((s,u)=>{let t=[];i.pipe(this).on("md5",r=>{t.push(r);}).on("error",u).on("finish",()=>{s(t[0]);});})}function X(i,s){let u=new y(s),t=L.call(u,i);return {stream:u,result:t}}exports.MD5Stream=y;exports.createMD5Stream=W;exports.fromStream=X;exports.pipeThroughMD5=L;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=md5-stream.js.map
|
|
1
|
+
import {Transform}from'stream';function B(i,s){return i+s&4294967295}var l=B;function v(i,s,u,t,r){let e=r||l;return s=e(e(s,i),e(u,t)),s}function w(i,s,u,t){var e=(t||l)(i<<s|i>>>32-s,u);return e}function g(i,s,u,t,r,e,n){return s=v(i,s,t,e,n),w(s,r,u,n)}function D(i,s,u,t,r,e,n,f){return g(u&t|~u&r,s,u,e,n,f,i)}function x(i,s,u,t,r,e,n,f){return g(u&r|t&~r,s,u,e,n,f,i)}function P(i,s,u,t,r,e,n,f){return g(u^t^r,s,u,e,n,f,i)}function S(i,s,u,t,r,e,n,f){return g(t^(u|~r),s,u,e,n,f,i)}function F(i,s,u){typeof u>"u"&&(u=l);let t=i[0],r=i[1],e=i[2],n=i[3],f=D.bind(null,u);t=f(t,r,e,n,s[0],7,-680876936),n=f(n,t,r,e,s[1],12,-389564586),e=f(e,n,t,r,s[2],17,606105819),r=f(r,e,n,t,s[3],22,-1044525330),t=f(t,r,e,n,s[4],7,-176418897),n=f(n,t,r,e,s[5],12,1200080426),e=f(e,n,t,r,s[6],17,-1473231341),r=f(r,e,n,t,s[7],22,-45705983),t=f(t,r,e,n,s[8],7,1770035416),n=f(n,t,r,e,s[9],12,-1958414417),e=f(e,n,t,r,s[10],17,-42063),r=f(r,e,n,t,s[11],22,-1990404162),t=f(t,r,e,n,s[12],7,1804603682),n=f(n,t,r,e,s[13],12,-40341101),e=f(e,n,t,r,s[14],17,-1502002290),r=f(r,e,n,t,s[15],22,1236535329);let o=x.bind(null,u);t=o(t,r,e,n,s[1],5,-165796510),n=o(n,t,r,e,s[6],9,-1069501632),e=o(e,n,t,r,s[11],14,643717713),r=o(r,e,n,t,s[0],20,-373897302),t=o(t,r,e,n,s[5],5,-701558691),n=o(n,t,r,e,s[10],9,38016083),e=o(e,n,t,r,s[15],14,-660478335),r=o(r,e,n,t,s[4],20,-405537848),t=o(t,r,e,n,s[9],5,568446438),n=o(n,t,r,e,s[14],9,-1019803690),e=o(e,n,t,r,s[3],14,-187363961),r=o(r,e,n,t,s[8],20,1163531501),t=o(t,r,e,n,s[13],5,-1444681467),n=o(n,t,r,e,s[2],9,-51403784),e=o(e,n,t,r,s[7],14,1735328473),r=o(r,e,n,t,s[12],20,-1926607734);let a=P.bind(null,u);t=a(t,r,e,n,s[5],4,-378558),n=a(n,t,r,e,s[8],11,-2022574463),e=a(e,n,t,r,s[11],16,1839030562),r=a(r,e,n,t,s[14],23,-35309556),t=a(t,r,e,n,s[1],4,-1530992060),n=a(n,t,r,e,s[4],11,1272893353),e=a(e,n,t,r,s[7],16,-155497632),r=a(r,e,n,t,s[10],23,-1094730640),t=a(t,r,e,n,s[13],4,681279174),n=a(n,t,r,e,s[0],11,-358537222),e=a(e,n,t,r,s[3],16,-722521979),r=a(r,e,n,t,s[6],23,76029189),t=a(t,r,e,n,s[9],4,-640364487),n=a(n,t,r,e,s[12],11,-421815835),e=a(e,n,t,r,s[15],16,530742520),r=a(r,e,n,t,s[2],23,-995338651);let b=S.bind(null,u);t=b(t,r,e,n,s[0],6,-198630844),n=b(n,t,r,e,s[7],10,1126891415),e=b(e,n,t,r,s[14],15,-1416354905),r=b(r,e,n,t,s[5],21,-57434055),t=b(t,r,e,n,s[12],6,1700485571),n=b(n,t,r,e,s[3],10,-1894986606),e=b(e,n,t,r,s[10],15,-1051523),r=b(r,e,n,t,s[1],21,-2054922799),t=b(t,r,e,n,s[8],6,1873313359),n=b(n,t,r,e,s[15],10,-30611744),e=b(e,n,t,r,s[6],15,-1560198380),r=b(r,e,n,t,s[13],21,1309151649),t=b(t,r,e,n,s[4],6,-145523070),n=b(n,t,r,e,s[11],10,-1120210379),e=b(e,n,t,r,s[2],15,718787259),r=b(r,e,n,t,s[9],21,-343485551),i[0]=u(t,i[0]),i[1]=u(r,i[1]),i[2]=u(e,i[2]),i[3]=u(n,i[3]);}var p=F;var R="0123456789abcdef".split(""),M=R;function C(i){let s="";for(let u=0;u<4;u++)s+=M[i>>u*8+4&15]+M[i>>u*8&15];return s}function O(i){let s=i.length,u=new Array(s);for(let t=0;t<s;t++)u[t]=C(i[t]);return u.join("")}var A=O;var y=class i extends Transform{constructor(u){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=u?.add32||l,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(u,t,r){try{let e=u,n=e.length;if(n===0){r();return}if(this.state.bufferLength>0){let a=this.state.bufferLength,b=64-a,c=Math.min(n,b);for(let m=0;m<c;m++)this.buffer[a+m]=e[m];if(this.state.bufferLength+=c,this.state.bufferLength===64&&this._processBufferBlock(),c===n){r();return}let d=n-c;for(let m=0;m<d;m++)e[m]=e[c+m];let h=Buffer.alloc(d);for(let m=0;m<d;m++)h[m]=e[m];e=h;}let f=Math.floor(e.length/64);for(let a=0;a<f;a++){let b=a*64,c=[];for(let d=0;d<16;d++){let h=b+d*4;c[d]=e[h]+(e[h+1]<<8)+(e[h+2]<<16)+(e[h+3]<<24);}p(this.state.state,c,this.add32),this.state.bytesProcessed+=64;}let o=e.length%64;if(o>0){this.buffer.length<o&&(this.buffer=new Uint8Array(o),this.state.buffer=this.buffer);for(let a=0;a<o;a++)this.buffer[a]=e[f*64+a];this.state.bufferLength=o;}r();}catch(e){r(e);}}_processBufferBlock(){let u=this.state.buffer,t=[];for(let r=0;r<16;r++){let e=r*4;t[r]=u[e]+(u[e+1]<<8)+(u[e+2]<<16)+(u[e+3]<<24);}p(this.state.state,t,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(u){try{let{state:t,bufferLength:r,buffer:e}=this.state,n=new Array(16).fill(0);for(let o=0;o<r;o++)n[o>>2]|=(e[o]&255)<<(o%4<<3);if(n[r>>2]|=128<<(r%4<<3),r>55){p(t,n,this.add32);for(let o=0;o<16;o++)n[o]=0;}n[14]=(this.state.bytesProcessed+r)*8,n[15]=0,p(t,n,this.add32);let f=A(t);this.emit("md5",{digest:f,bytesProcessed:this.state.bytesProcessed+r}),u();}catch(t){u(t);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(u,t){let r=new i(t),e=L.call(r,u);return {stream:r,result:e}}};function W(i){return new y(i)}async function L(i){return new Promise((s,u)=>{let t=[];i.pipe(this).on("md5",r=>{t.push(r);}).on("error",u).on("finish",()=>{s(t[0]);});})}function X(i,s){let u=new y(s),t=L.call(u,i);return {stream:u,result:t}}export{y as MD5Stream,W as createMD5Stream,X as fromStream,L as pipeThroughMD5};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';function P(i,t){return i+t&4294967295}var m=P;function S(i,t,a,e,n){let s=n||m;return t=s(s(t,i),s(a,e)),t}function w(i,t,a,e){var s=(e||m)(i<<t|i>>>32-t,a);return s}function h(i,t,a,e,n,s,r){return t=S(i,t,e,s,r),w(t,n,a,r)}function y(i,t,a,e,n,s,r,u){return h(a&e|~a&n,t,a,s,r,u,i)}function R(i,t,a,e,n,s,r,u){return h(a&n|e&~n,t,a,s,r,u,i)}function g(i,t,a,e,n,s,r,u){return h(a^e^n,t,a,s,r,u,i)}function D(i,t,a,e,n,s,r,u){return h(e^(a|~n),t,a,s,r,u,i)}function A(i,t,a){typeof a>"u"&&(a=m);let e=i[0],n=i[1],s=i[2],r=i[3],u=y.bind(null,a);e=u(e,n,s,r,t[0],7,-680876936),r=u(r,e,n,s,t[1],12,-389564586),s=u(s,r,e,n,t[2],17,606105819),n=u(n,s,r,e,t[3],22,-1044525330),e=u(e,n,s,r,t[4],7,-176418897),r=u(r,e,n,s,t[5],12,1200080426),s=u(s,r,e,n,t[6],17,-1473231341),n=u(n,s,r,e,t[7],22,-45705983),e=u(e,n,s,r,t[8],7,1770035416),r=u(r,e,n,s,t[9],12,-1958414417),s=u(s,r,e,n,t[10],17,-42063),n=u(n,s,r,e,t[11],22,-1990404162),e=u(e,n,s,r,t[12],7,1804603682),r=u(r,e,n,s,t[13],12,-40341101),s=u(s,r,e,n,t[14],17,-1502002290),n=u(n,s,r,e,t[15],22,1236535329);let o=R.bind(null,a);e=o(e,n,s,r,t[1],5,-165796510),r=o(r,e,n,s,t[6],9,-1069501632),s=o(s,r,e,n,t[11],14,643717713),n=o(n,s,r,e,t[0],20,-373897302),e=o(e,n,s,r,t[5],5,-701558691),r=o(r,e,n,s,t[10],9,38016083),s=o(s,r,e,n,t[15],14,-660478335),n=o(n,s,r,e,t[4],20,-405537848),e=o(e,n,s,r,t[9],5,568446438),r=o(r,e,n,s,t[14],9,-1019803690),s=o(s,r,e,n,t[3],14,-187363961),n=o(n,s,r,e,t[8],20,1163531501),e=o(e,n,s,r,t[13],5,-1444681467),r=o(r,e,n,s,t[2],9,-51403784),s=o(s,r,e,n,t[7],14,1735328473),n=o(n,s,r,e,t[12],20,-1926607734);let l=g.bind(null,a);e=l(e,n,s,r,t[5],4,-378558),r=l(r,e,n,s,t[8],11,-2022574463),s=l(s,r,e,n,t[11],16,1839030562),n=l(n,s,r,e,t[14],23,-35309556),e=l(e,n,s,r,t[1],4,-1530992060),r=l(r,e,n,s,t[4],11,1272893353),s=l(s,r,e,n,t[7],16,-155497632),n=l(n,s,r,e,t[10],23,-1094730640),e=l(e,n,s,r,t[13],4,681279174),r=l(r,e,n,s,t[0],11,-358537222),s=l(s,r,e,n,t[3],16,-722521979),n=l(n,s,r,e,t[6],23,76029189),e=l(e,n,s,r,t[9],4,-640364487),r=l(r,e,n,s,t[12],11,-421815835),s=l(s,r,e,n,t[15],16,530742520),n=l(n,s,r,e,t[2],23,-995338651);let b=D.bind(null,a);e=b(e,n,s,r,t[0],6,-198630844),r=b(r,e,n,s,t[7],10,1126891415),s=b(s,r,e,n,t[14],15,-1416354905),n=b(n,s,r,e,t[5],21,-57434055),e=b(e,n,s,r,t[12],6,1700485571),r=b(r,e,n,s,t[3],10,-1894986606),s=b(s,r,e,n,t[10],15,-1051523),n=b(n,s,r,e,t[1],21,-2054922799),e=b(e,n,s,r,t[8],6,1873313359),r=b(r,e,n,s,t[15],10,-30611744),s=b(s,r,e,n,t[6],15,-1560198380),n=b(n,s,r,e,t[13],21,1309151649),e=b(e,n,s,r,t[4],6,-145523070),r=b(r,e,n,s,t[11],10,-1120210379),s=b(s,r,e,n,t[2],15,718787259),n=b(n,s,r,e,t[9],21,-343485551),i[0]=a(e,i[0]),i[1]=a(n,i[1]),i[2]=a(s,i[2]),i[3]=a(r,i[3]);}var c=A;var v="0123456789abcdef".split(""),p=v;function B(i){let t="";for(let a=0;a<4;a++)t+=p[i>>a*8+4&15]+p[i>>a*8&15];return t}function x(i){let t=i.length,a=new Array(t);for(let e=0;e<t;e++)a[e]=B(i[e]);return a.join("")}var M=x;var F=[1732584193,-271733879,-1732584194,271733878],d=class i{constructor(t,a={}){this.result=null;this.resultResolver=null;this.consumed=false;this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.sourceStream=t,this.state={state:[...F],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.add32=a.add32||m,this.resultPromise=new Promise(e=>{this.resultResolver=e;});}getReader(){if(this.consumed)throw new Error("Cannot get reader from MD5ReadableStream: stream has already been consumed");this.consumed=true;let{readable:t,writable:a}=new TransformStream({transform:async(e,n)=>{await this.processChunk(e),n.enqueue(e);},flush:async e=>{this.finalize(),this.resultResolver&&this.resultResolver(this.result);}});return this.sourceStream.pipeTo(a).catch(e=>{console.error("Error piping stream:",e),this.resultResolver&&this.resultResolver({digest:"",bytesProcessed:this.state.bytesProcessed});}),t.getReader()}async processChunk(t){let a;t instanceof Blob?a=new Uint8Array(await t.arrayBuffer()):t instanceof ArrayBuffer?a=new Uint8Array(t):a=t;let e=a.length;if(e===0)return;if(this.state.bufferLength>0){let r=this.state.bufferLength,u=64-r,o=Math.min(e,u);for(let f=0;f<o;f++)this.buffer[r+f]=a[f];if(this.state.bufferLength+=o,this.state.bufferLength===64&&this._processBufferBlock(),o===e)return;let l=e-o,b=new Uint8Array(l);for(let f=0;f<l;f++)b[f]=a[o+f];a=b;}let n=Math.floor(a.length/64);for(let r=0;r<n;r++){let u=r*64,o=[];for(let l=0;l<16;l++){let b=u+l*4;o[l]=a[b]+(a[b+1]<<8)+(a[b+2]<<16)+(a[b+3]<<24);}c(this.state.state,o,this.add32),this.state.bytesProcessed+=64;}let s=a.length%64;if(s>0){this.buffer.length<s&&(this.buffer=new Uint8Array(s),this.state.buffer=this.buffer);for(let r=0;r<s;r++)this.buffer[r]=a[n+r];this.state.bufferLength=s;}}_processBufferBlock(){let t=this.state.buffer,a=[];for(let e=0;e<16;e++){let n=e*4;a[e]=t[n]+(t[n+1]<<8)+(t[n+2]<<16)+(t[n+3]<<24);}c(this.state.state,a,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}finalize(){let{state:t,bufferLength:a,buffer:e}=this.state,n=new Array(16).fill(0);for(let r=0;r<a;r++)n[r>>2]|=(e[r]&255)<<(r%4<<3);if(n[a>>2]|=128<<(a%4<<3),a>55){c(t,n,this.add32);for(let r=0;r<16;r++)n[r]=0;}n[14]=(this.state.bytesProcessed+a)*8,n[15]=0,c(t,n,this.add32);let s=M(t);this.result={digest:s,bytesProcessed:this.state.bytesProcessed+a};}getResult(){return this.resultPromise}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}static hash(t,a){let e=new i(t,a),n=e.getReader();return new Promise((s,r)=>{let u=0;n.read().then(function o({done:l,value:b}){if(l){s(e.getResult());return}u+=b.length,n.read().then(o);}).catch(r);})}static hashFile(t,a){let e=t.stream();return i.hash(e,a)}static hashBlob(t,a){return new Promise((e,n)=>{let s=new FileReader;s.onload=r=>{try{let u=r.target?.result,o=new ReadableStream({start(l){l.enqueue(new Uint8Array(u)),l.close();}});e(i.hash(o,a));}catch(u){n(u);}},s.onerror=()=>n(s.error),s.readAsArrayBuffer(t);})}};function H(i,t){return new d(i,t)}async function I(i,t){let a=i.getReader(),e=new d(i,t),n=0;for(;;){let{done:s,value:r}=await a.read();if(s)break;r&&(n+=r.length);}return e.getResult()}async function J(i,t){return d.hashFile(i,t)}async function K(i,t){return d.hashBlob(i,t)}async function N(i,t){let a=i.getReader(),e=new d(i,t),n=0;for(;;){let{done:s,value:r}=await a.read();if(s)break;r&&(n+=r.length);}return e.getResult()}exports.MD5ReadableStream=d;exports.consumeWithMD5=N;exports.createMD5ReadableStream=H;exports.hashBlob=K;exports.hashFile=J;exports.hashReadableStream=I
|
|
2
|
-
//# sourceMappingURL=whatwg-stream.cjs.map
|
|
1
|
+
'use strict';function P(i,t){return i+t&4294967295}var m=P;function S(i,t,a,e,n){let s=n||m;return t=s(s(t,i),s(a,e)),t}function w(i,t,a,e){var s=(e||m)(i<<t|i>>>32-t,a);return s}function h(i,t,a,e,n,s,r){return t=S(i,t,e,s,r),w(t,n,a,r)}function y(i,t,a,e,n,s,r,u){return h(a&e|~a&n,t,a,s,r,u,i)}function R(i,t,a,e,n,s,r,u){return h(a&n|e&~n,t,a,s,r,u,i)}function g(i,t,a,e,n,s,r,u){return h(a^e^n,t,a,s,r,u,i)}function D(i,t,a,e,n,s,r,u){return h(e^(a|~n),t,a,s,r,u,i)}function A(i,t,a){typeof a>"u"&&(a=m);let e=i[0],n=i[1],s=i[2],r=i[3],u=y.bind(null,a);e=u(e,n,s,r,t[0],7,-680876936),r=u(r,e,n,s,t[1],12,-389564586),s=u(s,r,e,n,t[2],17,606105819),n=u(n,s,r,e,t[3],22,-1044525330),e=u(e,n,s,r,t[4],7,-176418897),r=u(r,e,n,s,t[5],12,1200080426),s=u(s,r,e,n,t[6],17,-1473231341),n=u(n,s,r,e,t[7],22,-45705983),e=u(e,n,s,r,t[8],7,1770035416),r=u(r,e,n,s,t[9],12,-1958414417),s=u(s,r,e,n,t[10],17,-42063),n=u(n,s,r,e,t[11],22,-1990404162),e=u(e,n,s,r,t[12],7,1804603682),r=u(r,e,n,s,t[13],12,-40341101),s=u(s,r,e,n,t[14],17,-1502002290),n=u(n,s,r,e,t[15],22,1236535329);let o=R.bind(null,a);e=o(e,n,s,r,t[1],5,-165796510),r=o(r,e,n,s,t[6],9,-1069501632),s=o(s,r,e,n,t[11],14,643717713),n=o(n,s,r,e,t[0],20,-373897302),e=o(e,n,s,r,t[5],5,-701558691),r=o(r,e,n,s,t[10],9,38016083),s=o(s,r,e,n,t[15],14,-660478335),n=o(n,s,r,e,t[4],20,-405537848),e=o(e,n,s,r,t[9],5,568446438),r=o(r,e,n,s,t[14],9,-1019803690),s=o(s,r,e,n,t[3],14,-187363961),n=o(n,s,r,e,t[8],20,1163531501),e=o(e,n,s,r,t[13],5,-1444681467),r=o(r,e,n,s,t[2],9,-51403784),s=o(s,r,e,n,t[7],14,1735328473),n=o(n,s,r,e,t[12],20,-1926607734);let l=g.bind(null,a);e=l(e,n,s,r,t[5],4,-378558),r=l(r,e,n,s,t[8],11,-2022574463),s=l(s,r,e,n,t[11],16,1839030562),n=l(n,s,r,e,t[14],23,-35309556),e=l(e,n,s,r,t[1],4,-1530992060),r=l(r,e,n,s,t[4],11,1272893353),s=l(s,r,e,n,t[7],16,-155497632),n=l(n,s,r,e,t[10],23,-1094730640),e=l(e,n,s,r,t[13],4,681279174),r=l(r,e,n,s,t[0],11,-358537222),s=l(s,r,e,n,t[3],16,-722521979),n=l(n,s,r,e,t[6],23,76029189),e=l(e,n,s,r,t[9],4,-640364487),r=l(r,e,n,s,t[12],11,-421815835),s=l(s,r,e,n,t[15],16,530742520),n=l(n,s,r,e,t[2],23,-995338651);let b=D.bind(null,a);e=b(e,n,s,r,t[0],6,-198630844),r=b(r,e,n,s,t[7],10,1126891415),s=b(s,r,e,n,t[14],15,-1416354905),n=b(n,s,r,e,t[5],21,-57434055),e=b(e,n,s,r,t[12],6,1700485571),r=b(r,e,n,s,t[3],10,-1894986606),s=b(s,r,e,n,t[10],15,-1051523),n=b(n,s,r,e,t[1],21,-2054922799),e=b(e,n,s,r,t[8],6,1873313359),r=b(r,e,n,s,t[15],10,-30611744),s=b(s,r,e,n,t[6],15,-1560198380),n=b(n,s,r,e,t[13],21,1309151649),e=b(e,n,s,r,t[4],6,-145523070),r=b(r,e,n,s,t[11],10,-1120210379),s=b(s,r,e,n,t[2],15,718787259),n=b(n,s,r,e,t[9],21,-343485551),i[0]=a(e,i[0]),i[1]=a(n,i[1]),i[2]=a(s,i[2]),i[3]=a(r,i[3]);}var c=A;var v="0123456789abcdef".split(""),p=v;function B(i){let t="";for(let a=0;a<4;a++)t+=p[i>>a*8+4&15]+p[i>>a*8&15];return t}function x(i){let t=i.length,a=new Array(t);for(let e=0;e<t;e++)a[e]=B(i[e]);return a.join("")}var M=x;var F=[1732584193,-271733879,-1732584194,271733878],d=class i{constructor(t,a={}){this.result=null;this.resultResolver=null;this.consumed=false;this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.sourceStream=t,this.state={state:[...F],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.add32=a.add32||m,this.resultPromise=new Promise(e=>{this.resultResolver=e;});}getReader(){if(this.consumed)throw new Error("Cannot get reader from MD5ReadableStream: stream has already been consumed");this.consumed=true;let{readable:t,writable:a}=new TransformStream({transform:async(e,n)=>{await this.processChunk(e),n.enqueue(e);},flush:async e=>{this.finalize(),this.resultResolver&&this.resultResolver(this.result);}});return this.sourceStream.pipeTo(a).catch(e=>{console.error("Error piping stream:",e),this.resultResolver&&this.resultResolver({digest:"",bytesProcessed:this.state.bytesProcessed});}),t.getReader()}async processChunk(t){let a;t instanceof Blob?a=new Uint8Array(await t.arrayBuffer()):t instanceof ArrayBuffer?a=new Uint8Array(t):a=t;let e=a.length;if(e===0)return;if(this.state.bufferLength>0){let r=this.state.bufferLength,u=64-r,o=Math.min(e,u);for(let f=0;f<o;f++)this.buffer[r+f]=a[f];if(this.state.bufferLength+=o,this.state.bufferLength===64&&this._processBufferBlock(),o===e)return;let l=e-o,b=new Uint8Array(l);for(let f=0;f<l;f++)b[f]=a[o+f];a=b;}let n=Math.floor(a.length/64);for(let r=0;r<n;r++){let u=r*64,o=[];for(let l=0;l<16;l++){let b=u+l*4;o[l]=a[b]+(a[b+1]<<8)+(a[b+2]<<16)+(a[b+3]<<24);}c(this.state.state,o,this.add32),this.state.bytesProcessed+=64;}let s=a.length%64;if(s>0){this.buffer.length<s&&(this.buffer=new Uint8Array(s),this.state.buffer=this.buffer);for(let r=0;r<s;r++)this.buffer[r]=a[n+r];this.state.bufferLength=s;}}_processBufferBlock(){let t=this.state.buffer,a=[];for(let e=0;e<16;e++){let n=e*4;a[e]=t[n]+(t[n+1]<<8)+(t[n+2]<<16)+(t[n+3]<<24);}c(this.state.state,a,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}finalize(){let{state:t,bufferLength:a,buffer:e}=this.state,n=new Array(16).fill(0);for(let r=0;r<a;r++)n[r>>2]|=(e[r]&255)<<(r%4<<3);if(n[a>>2]|=128<<(a%4<<3),a>55){c(t,n,this.add32);for(let r=0;r<16;r++)n[r]=0;}n[14]=(this.state.bytesProcessed+a)*8,n[15]=0,c(t,n,this.add32);let s=M(t);this.result={digest:s,bytesProcessed:this.state.bytesProcessed+a};}getResult(){return this.resultPromise}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}static hash(t,a){let e=new i(t,a),n=e.getReader();return new Promise((s,r)=>{let u=0;n.read().then(function o({done:l,value:b}){if(l){s(e.getResult());return}u+=b.length,n.read().then(o);}).catch(r);})}static hashFile(t,a){let e=t.stream();return i.hash(e,a)}static hashBlob(t,a){return new Promise((e,n)=>{let s=new FileReader;s.onload=r=>{try{let u=r.target?.result,o=new ReadableStream({start(l){l.enqueue(new Uint8Array(u)),l.close();}});e(i.hash(o,a));}catch(u){n(u);}},s.onerror=()=>n(s.error),s.readAsArrayBuffer(t);})}};function H(i,t){return new d(i,t)}async function I(i,t){let a=i.getReader(),e=new d(i,t),n=0;for(;;){let{done:s,value:r}=await a.read();if(s)break;r&&(n+=r.length);}return e.getResult()}async function J(i,t){return d.hashFile(i,t)}async function K(i,t){return d.hashBlob(i,t)}async function N(i,t){let a=i.getReader(),e=new d(i,t),n=0;for(;;){let{done:s,value:r}=await a.read();if(s)break;r&&(n+=r.length);}return e.getResult()}exports.MD5ReadableStream=d;exports.consumeWithMD5=N;exports.createMD5ReadableStream=H;exports.hashBlob=K;exports.hashFile=J;exports.hashReadableStream=I;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=whatwg-stream.js.map
|
|
1
|
+
function P(i,t){return i+t&4294967295}var m=P;function S(i,t,a,e,n){let s=n||m;return t=s(s(t,i),s(a,e)),t}function w(i,t,a,e){var s=(e||m)(i<<t|i>>>32-t,a);return s}function h(i,t,a,e,n,s,r){return t=S(i,t,e,s,r),w(t,n,a,r)}function y(i,t,a,e,n,s,r,u){return h(a&e|~a&n,t,a,s,r,u,i)}function R(i,t,a,e,n,s,r,u){return h(a&n|e&~n,t,a,s,r,u,i)}function g(i,t,a,e,n,s,r,u){return h(a^e^n,t,a,s,r,u,i)}function D(i,t,a,e,n,s,r,u){return h(e^(a|~n),t,a,s,r,u,i)}function A(i,t,a){typeof a>"u"&&(a=m);let e=i[0],n=i[1],s=i[2],r=i[3],u=y.bind(null,a);e=u(e,n,s,r,t[0],7,-680876936),r=u(r,e,n,s,t[1],12,-389564586),s=u(s,r,e,n,t[2],17,606105819),n=u(n,s,r,e,t[3],22,-1044525330),e=u(e,n,s,r,t[4],7,-176418897),r=u(r,e,n,s,t[5],12,1200080426),s=u(s,r,e,n,t[6],17,-1473231341),n=u(n,s,r,e,t[7],22,-45705983),e=u(e,n,s,r,t[8],7,1770035416),r=u(r,e,n,s,t[9],12,-1958414417),s=u(s,r,e,n,t[10],17,-42063),n=u(n,s,r,e,t[11],22,-1990404162),e=u(e,n,s,r,t[12],7,1804603682),r=u(r,e,n,s,t[13],12,-40341101),s=u(s,r,e,n,t[14],17,-1502002290),n=u(n,s,r,e,t[15],22,1236535329);let o=R.bind(null,a);e=o(e,n,s,r,t[1],5,-165796510),r=o(r,e,n,s,t[6],9,-1069501632),s=o(s,r,e,n,t[11],14,643717713),n=o(n,s,r,e,t[0],20,-373897302),e=o(e,n,s,r,t[5],5,-701558691),r=o(r,e,n,s,t[10],9,38016083),s=o(s,r,e,n,t[15],14,-660478335),n=o(n,s,r,e,t[4],20,-405537848),e=o(e,n,s,r,t[9],5,568446438),r=o(r,e,n,s,t[14],9,-1019803690),s=o(s,r,e,n,t[3],14,-187363961),n=o(n,s,r,e,t[8],20,1163531501),e=o(e,n,s,r,t[13],5,-1444681467),r=o(r,e,n,s,t[2],9,-51403784),s=o(s,r,e,n,t[7],14,1735328473),n=o(n,s,r,e,t[12],20,-1926607734);let l=g.bind(null,a);e=l(e,n,s,r,t[5],4,-378558),r=l(r,e,n,s,t[8],11,-2022574463),s=l(s,r,e,n,t[11],16,1839030562),n=l(n,s,r,e,t[14],23,-35309556),e=l(e,n,s,r,t[1],4,-1530992060),r=l(r,e,n,s,t[4],11,1272893353),s=l(s,r,e,n,t[7],16,-155497632),n=l(n,s,r,e,t[10],23,-1094730640),e=l(e,n,s,r,t[13],4,681279174),r=l(r,e,n,s,t[0],11,-358537222),s=l(s,r,e,n,t[3],16,-722521979),n=l(n,s,r,e,t[6],23,76029189),e=l(e,n,s,r,t[9],4,-640364487),r=l(r,e,n,s,t[12],11,-421815835),s=l(s,r,e,n,t[15],16,530742520),n=l(n,s,r,e,t[2],23,-995338651);let b=D.bind(null,a);e=b(e,n,s,r,t[0],6,-198630844),r=b(r,e,n,s,t[7],10,1126891415),s=b(s,r,e,n,t[14],15,-1416354905),n=b(n,s,r,e,t[5],21,-57434055),e=b(e,n,s,r,t[12],6,1700485571),r=b(r,e,n,s,t[3],10,-1894986606),s=b(s,r,e,n,t[10],15,-1051523),n=b(n,s,r,e,t[1],21,-2054922799),e=b(e,n,s,r,t[8],6,1873313359),r=b(r,e,n,s,t[15],10,-30611744),s=b(s,r,e,n,t[6],15,-1560198380),n=b(n,s,r,e,t[13],21,1309151649),e=b(e,n,s,r,t[4],6,-145523070),r=b(r,e,n,s,t[11],10,-1120210379),s=b(s,r,e,n,t[2],15,718787259),n=b(n,s,r,e,t[9],21,-343485551),i[0]=a(e,i[0]),i[1]=a(n,i[1]),i[2]=a(s,i[2]),i[3]=a(r,i[3]);}var c=A;var v="0123456789abcdef".split(""),p=v;function B(i){let t="";for(let a=0;a<4;a++)t+=p[i>>a*8+4&15]+p[i>>a*8&15];return t}function x(i){let t=i.length,a=new Array(t);for(let e=0;e<t;e++)a[e]=B(i[e]);return a.join("")}var M=x;var F=[1732584193,-271733879,-1732584194,271733878],d=class i{constructor(t,a={}){this.result=null;this.resultResolver=null;this.consumed=false;this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.sourceStream=t,this.state={state:[...F],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.add32=a.add32||m,this.resultPromise=new Promise(e=>{this.resultResolver=e;});}getReader(){if(this.consumed)throw new Error("Cannot get reader from MD5ReadableStream: stream has already been consumed");this.consumed=true;let{readable:t,writable:a}=new TransformStream({transform:async(e,n)=>{await this.processChunk(e),n.enqueue(e);},flush:async e=>{this.finalize(),this.resultResolver&&this.resultResolver(this.result);}});return this.sourceStream.pipeTo(a).catch(e=>{console.error("Error piping stream:",e),this.resultResolver&&this.resultResolver({digest:"",bytesProcessed:this.state.bytesProcessed});}),t.getReader()}async processChunk(t){let a;t instanceof Blob?a=new Uint8Array(await t.arrayBuffer()):t instanceof ArrayBuffer?a=new Uint8Array(t):a=t;let e=a.length;if(e===0)return;if(this.state.bufferLength>0){let r=this.state.bufferLength,u=64-r,o=Math.min(e,u);for(let f=0;f<o;f++)this.buffer[r+f]=a[f];if(this.state.bufferLength+=o,this.state.bufferLength===64&&this._processBufferBlock(),o===e)return;let l=e-o,b=new Uint8Array(l);for(let f=0;f<l;f++)b[f]=a[o+f];a=b;}let n=Math.floor(a.length/64);for(let r=0;r<n;r++){let u=r*64,o=[];for(let l=0;l<16;l++){let b=u+l*4;o[l]=a[b]+(a[b+1]<<8)+(a[b+2]<<16)+(a[b+3]<<24);}c(this.state.state,o,this.add32),this.state.bytesProcessed+=64;}let s=a.length%64;if(s>0){this.buffer.length<s&&(this.buffer=new Uint8Array(s),this.state.buffer=this.buffer);for(let r=0;r<s;r++)this.buffer[r]=a[n+r];this.state.bufferLength=s;}}_processBufferBlock(){let t=this.state.buffer,a=[];for(let e=0;e<16;e++){let n=e*4;a[e]=t[n]+(t[n+1]<<8)+(t[n+2]<<16)+(t[n+3]<<24);}c(this.state.state,a,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}finalize(){let{state:t,bufferLength:a,buffer:e}=this.state,n=new Array(16).fill(0);for(let r=0;r<a;r++)n[r>>2]|=(e[r]&255)<<(r%4<<3);if(n[a>>2]|=128<<(a%4<<3),a>55){c(t,n,this.add32);for(let r=0;r<16;r++)n[r]=0;}n[14]=(this.state.bytesProcessed+a)*8,n[15]=0,c(t,n,this.add32);let s=M(t);this.result={digest:s,bytesProcessed:this.state.bytesProcessed+a};}getResult(){return this.resultPromise}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}static hash(t,a){let e=new i(t,a),n=e.getReader();return new Promise((s,r)=>{let u=0;n.read().then(function o({done:l,value:b}){if(l){s(e.getResult());return}u+=b.length,n.read().then(o);}).catch(r);})}static hashFile(t,a){let e=t.stream();return i.hash(e,a)}static hashBlob(t,a){return new Promise((e,n)=>{let s=new FileReader;s.onload=r=>{try{let u=r.target?.result,o=new ReadableStream({start(l){l.enqueue(new Uint8Array(u)),l.close();}});e(i.hash(o,a));}catch(u){n(u);}},s.onerror=()=>n(s.error),s.readAsArrayBuffer(t);})}};function H(i,t){return new d(i,t)}async function I(i,t){let a=i.getReader(),e=new d(i,t),n=0;for(;;){let{done:s,value:r}=await a.read();if(s)break;r&&(n+=r.length);}return e.getResult()}async function J(i,t){return d.hashFile(i,t)}async function K(i,t){return d.hashBlob(i,t)}async function N(i,t){let a=i.getReader(),e=new d(i,t),n=0;for(;;){let{done:s,value:r}=await a.read();if(s)break;r&&(n+=r.length);}return e.getResult()}export{d as MD5ReadableStream,N as consumeWithMD5,H as createMD5ReadableStream,K as hashBlob,J as hashFile,I as hashReadableStream};
|