@loaders.gl/crypto 4.0.0-alpha.5 → 4.0.0-alpha.7
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/dist/bundle.js +2 -2
- package/dist/crypto-worker-node.js +2 -0
- package/dist/crypto-worker-node.js.map +7 -0
- package/dist/crypto-worker.js +2 -0
- package/dist/crypto-worker.js.map +7 -0
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +2 -2
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +83 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/algorithms/crc32.js +41 -0
- package/dist/es5/lib/algorithms/crc32.js.map +1 -0
- package/dist/es5/lib/algorithms/crc32c.js +44 -0
- package/dist/es5/lib/algorithms/crc32c.js.map +1 -0
- package/dist/es5/lib/algorithms/md5-wasm.js +436 -0
- package/dist/es5/lib/algorithms/md5-wasm.js.map +1 -0
- package/dist/es5/lib/crc32-hash.js +150 -0
- package/dist/es5/lib/crc32-hash.js.map +1 -0
- package/dist/es5/lib/crc32c-hash.js +149 -0
- package/dist/es5/lib/crc32c-hash.js.map +1 -0
- package/dist/es5/lib/crypto-hash.js +186 -0
- package/dist/es5/lib/crypto-hash.js.map +1 -0
- package/dist/es5/lib/hash.js +149 -0
- package/dist/es5/lib/hash.js.map +1 -0
- package/dist/es5/lib/md5-hash.js +66 -0
- package/dist/es5/lib/md5-hash.js.map +1 -0
- package/dist/es5/lib/node-hash.js +147 -0
- package/dist/es5/lib/node-hash.js.map +1 -0
- package/dist/es5/lib/sha256-hash.js +33 -0
- package/dist/es5/lib/sha256-hash.js.map +1 -0
- package/dist/es5/lib/utils/base64-utils.js +55 -0
- package/dist/es5/lib/utils/base64-utils.js.map +1 -0
- package/dist/es5/lib/utils/digest-utils.js +23 -0
- package/dist/es5/lib/utils/digest-utils.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/workers/worker.js +65 -0
- package/dist/es5/workers/worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/index.js +27 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/algorithms/crc32.js +24 -0
- package/dist/esm/lib/algorithms/crc32.js.map +1 -0
- package/dist/esm/lib/algorithms/crc32c.js +27 -0
- package/dist/esm/lib/algorithms/crc32c.js.map +1 -0
- package/dist/esm/lib/algorithms/md5-wasm.js +428 -0
- package/dist/esm/lib/algorithms/md5-wasm.js.map +1 -0
- package/dist/esm/lib/crc32-hash.js +43 -0
- package/dist/esm/lib/crc32-hash.js.map +1 -0
- package/dist/esm/lib/crc32c-hash.js +42 -0
- package/dist/esm/lib/crc32c-hash.js.map +1 -0
- package/dist/esm/lib/crypto-hash.js +54 -0
- package/dist/esm/lib/crypto-hash.js.map +1 -0
- package/dist/esm/lib/hash.js +30 -0
- package/dist/esm/lib/hash.js.map +1 -0
- package/dist/esm/lib/md5-hash.js +19 -0
- package/dist/esm/lib/md5-hash.js.map +1 -0
- package/dist/esm/lib/node-hash.js +38 -0
- package/dist/esm/lib/node-hash.js.map +1 -0
- package/dist/esm/lib/sha256-hash.js +13 -0
- package/dist/esm/lib/sha256-hash.js.map +1 -0
- package/dist/esm/lib/utils/base64-utils.js +49 -0
- package/dist/esm/lib/utils/base64-utils.js.map +1 -0
- package/dist/esm/lib/utils/digest-utils.js +14 -0
- package/dist/esm/lib/utils/digest-utils.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/workers/cryptojs-worker.ts.disabled +26 -0
- package/dist/esm/workers/worker.js +22 -0
- package/dist/esm/workers/worker.js.map +1 -0
- package/dist/index.js +45 -25
- package/dist/lib/algorithms/crc32.js +25 -26
- package/dist/lib/algorithms/crc32c.js +33 -29
- package/dist/lib/algorithms/md5-wasm.js +414 -449
- package/dist/lib/crc32-hash.js +45 -54
- package/dist/lib/crc32c-hash.js +49 -53
- package/dist/lib/crypto-hash.d.ts +1 -1
- package/dist/lib/crypto-hash.d.ts.map +1 -1
- package/dist/lib/crypto-hash.js +55 -70
- package/dist/lib/hash.d.ts +1 -1
- package/dist/lib/hash.d.ts.map +1 -1
- package/dist/lib/hash.js +27 -36
- package/dist/lib/md5-hash.js +31 -22
- package/dist/lib/node-hash.d.ts +1 -1
- package/dist/lib/node-hash.d.ts.map +1 -1
- package/dist/lib/node-hash.js +39 -49
- package/dist/lib/sha256-hash.d.ts +1 -1
- package/dist/lib/sha256-hash.d.ts.map +1 -1
- package/dist/lib/sha256-hash.js +13 -11
- package/dist/lib/utils/base64-utils.js +62 -57
- package/dist/lib/utils/digest-utils.js +25 -13
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/workers/worker.js +22 -24
- package/package.json +10 -9
- package/src/lib/hash.ts +1 -1
- package/dist/bundle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/algorithms/crc32.js.map +0 -1
- package/dist/lib/algorithms/crc32c.js.map +0 -1
- package/dist/lib/algorithms/md5-wasm.js.map +0 -1
- package/dist/lib/crc32-hash.js.map +0 -1
- package/dist/lib/crc32c-hash.js.map +0 -1
- package/dist/lib/crypto-hash.js.map +0 -1
- package/dist/lib/hash.js.map +0 -1
- package/dist/lib/md5-hash.js.map +0 -1
- package/dist/lib/node-hash.js.map +0 -1
- package/dist/lib/sha256-hash.js.map +0 -1
- package/dist/lib/utils/base64-utils.js.map +0 -1
- package/dist/lib/utils/digest-utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/worker.js +0 -2
- package/dist/worker.js.map +0 -7
- package/dist/workers/worker.js.map +0 -1
- /package/dist/{workers → es5/workers}/cryptojs-worker.ts.disabled +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Hash } from './hash';
|
|
3
|
+
import CRC32C from './algorithms/crc32c';
|
|
4
|
+
import { toHex, hexToBase64 } from './utils/digest-utils';
|
|
5
|
+
export class CRC32CHash extends Hash {
|
|
6
|
+
constructor() {
|
|
7
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8
|
+
super();
|
|
9
|
+
_defineProperty(this, "name", 'crc32c');
|
|
10
|
+
_defineProperty(this, "options", void 0);
|
|
11
|
+
_defineProperty(this, "_hash", void 0);
|
|
12
|
+
this.options = {
|
|
13
|
+
crypto: {},
|
|
14
|
+
...options
|
|
15
|
+
};
|
|
16
|
+
this._hash = new CRC32C(options);
|
|
17
|
+
}
|
|
18
|
+
async hash(input) {
|
|
19
|
+
return this.hashSync(input);
|
|
20
|
+
}
|
|
21
|
+
hashSync(input) {
|
|
22
|
+
this._hash.update(input);
|
|
23
|
+
const hashValue = this._hash.finalize();
|
|
24
|
+
const hex = toHex(hashValue);
|
|
25
|
+
const hash = hexToBase64(hex);
|
|
26
|
+
return hash;
|
|
27
|
+
}
|
|
28
|
+
async *hashBatches(asyncIterator) {
|
|
29
|
+
var _this$options$crypto, _this$options$crypto$;
|
|
30
|
+
for await (const chunk of asyncIterator) {
|
|
31
|
+
this._hash.update(chunk);
|
|
32
|
+
yield chunk;
|
|
33
|
+
}
|
|
34
|
+
const hashValue = this._hash.finalize();
|
|
35
|
+
const hex = toHex(hashValue);
|
|
36
|
+
const hash = hexToBase64(hex);
|
|
37
|
+
(_this$options$crypto = this.options.crypto) === null || _this$options$crypto === void 0 ? void 0 : (_this$options$crypto$ = _this$options$crypto.onEnd) === null || _this$options$crypto$ === void 0 ? void 0 : _this$options$crypto$.call(_this$options$crypto, {
|
|
38
|
+
hash
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=crc32c-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32c-hash.js","names":["Hash","CRC32C","toHex","hexToBase64","CRC32CHash","constructor","options","arguments","length","undefined","_defineProperty","crypto","_hash","hash","input","hashSync","update","hashValue","finalize","hex","hashBatches","asyncIterator","_this$options$crypto","_this$options$crypto$","chunk","onEnd","call"],"sources":["../../../src/lib/crc32c-hash.ts"],"sourcesContent":["// CRC32c\nimport {Hash} from './hash';\nimport CRC32C from './algorithms/crc32c';\nimport {toHex, hexToBase64} from './utils/digest-utils';\n\n/**\n * A transform that calculates CRC32c Hash\n */\nexport class CRC32CHash extends Hash {\n readonly name = 'crc32c';\n\n options;\n private _hash: CRC32C;\n\n /**\n * Atomic hash calculation\n * @returns base64 encoded hash\n */\n constructor(options = {}) {\n super();\n this.options = {crypto: {}, ...options};\n this._hash = new CRC32C(options);\n }\n\n /**\n * Atomic hash calculation\n * @returns base64 encoded hash\n */\n async hash(input: ArrayBuffer): Promise<string> {\n return this.hashSync(input);\n }\n\n hashSync(input: ArrayBuffer): string {\n this._hash.update(input);\n const hashValue = this._hash.finalize();\n const hex = toHex(hashValue);\n const hash = hexToBase64(hex);\n return hash;\n }\n\n // runInBatches inherited\n\n async *hashBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n for await (const chunk of asyncIterator) {\n this._hash.update(chunk);\n yield chunk;\n }\n const hashValue = this._hash.finalize();\n const hex = toHex(hashValue);\n const hash = hexToBase64(hex);\n this.options.crypto?.onEnd?.({hash});\n }\n}\n"],"mappings":";AACA,SAAQA,IAAI,QAAO,QAAQ;AAC3B,OAAOC,MAAM,MAAM,qBAAqB;AACxC,SAAQC,KAAK,EAAEC,WAAW,QAAO,sBAAsB;AAKvD,OAAO,MAAMC,UAAU,SAASJ,IAAI,CAAC;EAUnCK,WAAWA,CAAA,EAAe;IAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtB,KAAK,C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
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Hash } from './hash';
|
|
3
|
+
let CryptoJS;
|
|
4
|
+
export class CryptoHash extends Hash {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
var _this$options, _this$options$crypto;
|
|
7
|
+
super();
|
|
8
|
+
_defineProperty(this, "name", void 0);
|
|
9
|
+
_defineProperty(this, "options", void 0);
|
|
10
|
+
_defineProperty(this, "_algorithm", void 0);
|
|
11
|
+
_defineProperty(this, "_hash", void 0);
|
|
12
|
+
this.options = options;
|
|
13
|
+
this._algorithm = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$crypto = _this$options.crypto) === null || _this$options$crypto === void 0 ? void 0 : _this$options$crypto.algorithm;
|
|
14
|
+
if (!this._algorithm) {
|
|
15
|
+
throw new Error(this.name);
|
|
16
|
+
}
|
|
17
|
+
this.name = this._algorithm.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
async preload() {
|
|
20
|
+
if (!CryptoJS) {
|
|
21
|
+
var _this$options2, _this$options2$module;
|
|
22
|
+
CryptoJS = (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : (_this$options2$module = _this$options2.modules) === null || _this$options2$module === void 0 ? void 0 : _this$options2$module.CryptoJS;
|
|
23
|
+
if (!CryptoJS) {
|
|
24
|
+
throw new Error(this.name);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!this._hash) {
|
|
28
|
+
const algo = CryptoJS.algo[this._algorithm];
|
|
29
|
+
this._hash = algo.create();
|
|
30
|
+
}
|
|
31
|
+
if (!this._hash) {
|
|
32
|
+
throw new Error(this.name);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async hash(input) {
|
|
36
|
+
await this.preload();
|
|
37
|
+
const typedWordArray = CryptoJS.lib.WordArray.create(input);
|
|
38
|
+
return this._hash.update(typedWordArray).finalize().toString(CryptoJS.enc.Base64);
|
|
39
|
+
}
|
|
40
|
+
async *hashBatches(asyncIterator) {
|
|
41
|
+
var _this$options3, _this$options3$crypto, _this$options3$crypto2;
|
|
42
|
+
await this.preload();
|
|
43
|
+
for await (const chunk of asyncIterator) {
|
|
44
|
+
const typedWordArray = CryptoJS.lib.WordArray.create(chunk);
|
|
45
|
+
this._hash.update(typedWordArray);
|
|
46
|
+
yield chunk;
|
|
47
|
+
}
|
|
48
|
+
const hash = this._hash.finalize().toString(CryptoJS.enc.Base64);
|
|
49
|
+
(_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : (_this$options3$crypto = _this$options3.crypto) === null || _this$options3$crypto === void 0 ? void 0 : (_this$options3$crypto2 = _this$options3$crypto.onEnd) === null || _this$options3$crypto2 === void 0 ? void 0 : _this$options3$crypto2.call(_this$options3$crypto, {
|
|
50
|
+
hash
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=crypto-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-hash.js","names":["Hash","CryptoJS","CryptoHash","constructor","options","_this$options","_this$options$crypto","_defineProperty","_algorithm","crypto","algorithm","Error","name","toLowerCase","preload","_this$options2","_this$options2$module","modules","_hash","algo","create","hash","input","typedWordArray","lib","WordArray","update","finalize","toString","enc","Base64","hashBatches","asyncIterator","_this$options3","_this$options3$crypto","_this$options3$crypto2","chunk","onEnd","call"],"sources":["../../../src/lib/crypto-hash.ts"],"sourcesContent":["// This dependency is too big, application must provide it\nimport type * as CryptoJSNamespace from 'crypto-js';\nimport {Hash} from './hash';\n\ntype CryptoHashOptions = {\n modules: {[moduleName: string]: any};\n crypto: {\n algorithm: string;\n onEnd?: (result: {hash: string}) => any;\n };\n};\n\nlet CryptoJS: typeof CryptoJSNamespace;\n\n/**\n * A transform that calculates Cryptographic Hash using Crypto JS library\n * @deprecated Warning, experimental class\n */\nexport class CryptoHash extends Hash {\n readonly name;\n\n options: CryptoHashOptions;\n private _algorithm;\n private _hash;\n\n constructor(options: CryptoHashOptions) {\n super();\n this.options = options;\n this._algorithm = this.options?.crypto?.algorithm;\n if (!this._algorithm) {\n throw new Error(this.name);\n }\n this.name = this._algorithm.toLowerCase();\n }\n\n async preload(): Promise<void> {\n if (!CryptoJS) {\n CryptoJS = this.options?.modules?.CryptoJS;\n if (!CryptoJS) {\n throw new Error(this.name);\n }\n }\n if (!this._hash) {\n const algo = CryptoJS.algo[this._algorithm];\n this._hash = algo.create();\n }\n if (!this._hash) {\n throw new Error(this.name);\n }\n }\n\n /**\n * Atomic hash calculation\n * @returns base64 encoded hash\n */\n async hash(input: ArrayBuffer): Promise<string> {\n await this.preload();\n // arrayBuffer is accepted, even though types and docs say no\n // https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer\n // @ts-expect-error\n const typedWordArray = CryptoJS.lib.WordArray.create(input);\n return this._hash.update(typedWordArray).finalize().toString(CryptoJS.enc.Base64);\n }\n\n async *hashBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n await this.preload();\n for await (const chunk of asyncIterator) {\n // arrayBuffer is accepted, even though types and docs say no\n // https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer\n // @ts-expect-error\n const typedWordArray = CryptoJS.lib.WordArray.create(chunk);\n this._hash.update(typedWordArray);\n yield chunk;\n }\n const hash = this._hash.finalize().toString(CryptoJS.enc.Base64);\n this.options?.crypto?.onEnd?.({hash});\n }\n}\n"],"mappings":";AAEA,SAAQA,IAAI,QAAO,QAAQ;AAU3B,IAAIC,QAAkC;AAMtC,OAAO,MAAMC,UAAU,SAASF,IAAI,CAAC;EAOnCG,WAAWA,CAACC,OAA0B,EAAE;IAAA,IAAAC,aAAA,EAAAC,oBAAA;IACtC,KAAK,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACR,IAAI,CAACH,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACI,UAAU,IA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C,QAAQ,CAAC3B,QAAQ,CAAC4B,GAAG,CAACC,MAAM,CAAC;EACnF;EAEA,OAAOC,WAAWA,CAChBC,aAAiE,EACrC;IAAA,IAAAC,cAAA,EAAAC,qBAAA,EAAAC,sBAAA;IAC5B,MAAM,IAAI,CAACrB,OAAO,CAAC,CAAC;IACpB,WAAW,MAAMsB,KAAK,IAAIJ,aAAa,EAAE;MAIvC,MAAMT,cAAc,GAAGtB,QAAQ,CAACuB,GAAG,CAACC,SAAS,CAACL,MAAM,CAACgB,KAAK,CAAC;MAC3D,IAAI,CAAClB,KAAK,CAACQ,MAAM,CAACH,cAAc,CAAC;MACjC,MAAMa,KAAK;IACb;IACA,MAAMf,IAAI,GAAG,IAAI,CAACH,KAAK,CAACS,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC3B,QAAQ,CAAC4B,GAAG,CAACC,MAAM,CAAC;IAChE,CAAAG,cAAA,OAAI,CAAC7B,OAAO,cAAA6B,cAAA,wBAAAC,qBAAA,GAAZD,cAAA,CAAcxB,MAAM,cAAAyB,qBAAA,wBAAAC,sBAAA,GAApBD,qBAAA,CAAsBG,KAAK,cAAAF,sBAAA,uBAA3BA,sBAAA,CAAAG,IAAA,CAAAJ,qBAAA,EAA8B;MAACb;IAAI,CAAC,CAAC;EACvC;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { concatenateArrayBuffersAsync } from '@loaders.gl/loader-utils';
|
|
3
|
+
export class Hash {
|
|
4
|
+
constructor() {
|
|
5
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
|
+
_defineProperty(this, "name", void 0);
|
|
7
|
+
_defineProperty(this, "options", void 0);
|
|
8
|
+
this.hashBatches = this.hashBatches.bind(this);
|
|
9
|
+
}
|
|
10
|
+
async preload() {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
async *hashBatches(asyncIterator) {
|
|
14
|
+
var _this$options$crypto, _this$options$crypto$;
|
|
15
|
+
const arrayBuffers = [];
|
|
16
|
+
for await (const arrayBuffer of asyncIterator) {
|
|
17
|
+
arrayBuffers.push(arrayBuffer);
|
|
18
|
+
yield arrayBuffer;
|
|
19
|
+
}
|
|
20
|
+
const output = await this.concatenate(arrayBuffers);
|
|
21
|
+
const hash = await this.hash(output);
|
|
22
|
+
(_this$options$crypto = this.options.crypto) === null || _this$options$crypto === void 0 ? void 0 : (_this$options$crypto$ = _this$options$crypto.onEnd) === null || _this$options$crypto$ === void 0 ? void 0 : _this$options$crypto$.call(_this$options$crypto, {
|
|
23
|
+
hash
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async concatenate(asyncIterator) {
|
|
27
|
+
return await concatenateArrayBuffersAsync(asyncIterator);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","names":["concatenateArrayBuffersAsync","Hash","constructor","options","arguments","length","undefined","_defineProperty","hashBatches","bind","preload","asyncIterator","_this$options$crypto","_this$options$crypto$","arrayBuffers","arrayBuffer","push","output","concatenate","hash","crypto","onEnd","call"],"sources":["../../../src/lib/hash.ts"],"sourcesContent":["// Hash\nimport {concatenateArrayBuffersAsync} from '@loaders.gl/loader-utils';\n\ntype HashOptions = {\n modules?: {[moduleName: string]: any};\n crypto?: {\n onEnd?: (result: {hash: string}) => any;\n };\n};\n\n/** Abstract hash base class */\nexport abstract class Hash {\n abstract readonly name: string;\n abstract readonly options: HashOptions;\n\n constructor(options: HashOptions = {}) {\n this.hashBatches = this.hashBatches.bind(this);\n }\n\n async preload(): Promise<void> {\n return;\n }\n\n abstract hash(arrayBuffer: ArrayBuffer): Promise<string>;\n\n async *hashBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n const arrayBuffers: ArrayBuffer[] = [];\n for await (const arrayBuffer of asyncIterator) {\n arrayBuffers.push(arrayBuffer);\n yield arrayBuffer;\n }\n const output = await this.concatenate(arrayBuffers);\n const hash = await this.hash(output);\n this.options.crypto?.onEnd?.({hash});\n }\n\n // HELPERS\n\n protected async concatenate(asyncIterator): Promise<ArrayBuffer> {\n return await concatenateArrayBuffersAsync(asyncIterator);\n }\n}\n"],"mappings":";AACA,SAAQA,4BAA4B,QAAO,0BAA0B;AAUrE,OAAO,MAAeC,IAAI,CAAC;EAIzBC,WAAWA,CAAA,EAA4B;IAAA,IAA3BC,OAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAAG,eAAA;IAAAA,eAAA;IACnC,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC;EAChD;EAEA,MAAMC,OAAOA,CAAA,EAAkB;IAC7B;EACF;EAIA,OAAOF,WAAWA,CAChBG,aAAiE,EACrC;IAAA,IAAAC,oBAAA,EAAAC,qBAAA;IAC5B,MAAMC,YAA2B,GAAG,EAAE;IACtC,WAAW,MAAMC,WAAW,IAAIJ,aAAa,EAAE;MAC7CG,YAAY,CAACE,IAAI,CAACD,WAAW,CAAC;MAC9B,MAAMA,WAAW;IACnB;IACA,MAAME,MAAM,GAAG,MAAM,IAAI,CAACC,WAAW,CAACJ,YAAY,CAAC;IACnD,MAAMK,IAAI,GAAG,MAAM,IAAI,CAACA,IAAI,CAACF,MAAM,CAAC;IACpC,CAAAL,oBAAA,OAAI,CAACT,OAAO,CAACiB,MAAM,cAAAR,oBAAA,wBAAAC,qBAAA,GAAnBD,oBAAA,CAAqBS,KAAK,cAAAR,qBAAA,uBAA1BA,qBAAA,CAAAS,IAAA,CAAAV,oBAAA,EAA6B;MAACO;IAAI,CAAC,CAAC;EACtC;EAIA,MAAgBD,WAAWA,CAACP,aAAa,EAAwB;IAC/D,OAAO,MAAMX,4BAA4B,CAACW,aAAa,CAAC;EAC1D;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Hash } from './hash';
|
|
3
|
+
import md5WASM from './algorithms/md5-wasm';
|
|
4
|
+
import { hexToBase64 } from './utils/digest-utils';
|
|
5
|
+
export class MD5Hash extends Hash {
|
|
6
|
+
constructor() {
|
|
7
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8
|
+
super();
|
|
9
|
+
_defineProperty(this, "name", 'md5');
|
|
10
|
+
_defineProperty(this, "options", void 0);
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
async hash(input) {
|
|
14
|
+
const md5Promise = new Promise((resolve, reject) => md5WASM(input).then(resolve).catch(reject));
|
|
15
|
+
const hex = await md5Promise;
|
|
16
|
+
return hexToBase64(hex);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=md5-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5-hash.js","names":["Hash","md5WASM","hexToBase64","MD5Hash","constructor","options","arguments","length","undefined","_defineProperty","hash","input","md5Promise","Promise","resolve","reject","then","catch","hex"],"sources":["../../../src/lib/md5-hash.ts"],"sourcesContent":["// Fork of https://github.com/briantbutton/md5-wasm under MIT license\nimport {Hash} from './hash';\nimport md5WASM from './algorithms/md5-wasm';\nimport {hexToBase64} from './utils/digest-utils';\n\n/**\n * A transform that calculates MD5 hashes, passing data through\n */\nexport class MD5Hash extends Hash {\n readonly name = 'md5';\n readonly options;\n\n constructor(options = {}) {\n super();\n this.options = options;\n }\n\n /**\n * Atomic hash calculation\n * @returns base64 encoded hash\n */\n async hash(input: ArrayBuffer): Promise<string> {\n const md5Promise = new Promise<string>((resolve, reject) =>\n // @ts-expect-error\n md5WASM(input).then(resolve).catch(reject)\n );\n const hex = await md5Promise;\n return hexToBase64(hex);\n }\n}\n"],"mappings":";AACA,SAAQA,IAAI,QAAO,QAAQ;AAC3B,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,SAAQC,WAAW,QAAO,sBAAsB;AAKhD,OAAO,MAAMC,OAAO,SAASH,IAAI,CAAC;EAIhCI,WAAWA,CAAA,EAAe;IAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtB,KAAK,CAAC,CAAC;IAACG,eAAA,eAJM,KAAK;IAAAA,eAAA;IAKnB,IAAI,CAACJ,OAAO,GAAGA,OAAO;EACxB;EAMA,MAAMK,IAAIA,CAACC,KAAkB,EAAmB;IAC9C,MAAMC,UAAU,GAAG,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAErDd,OAAO,CAACU,KAAK,CAAC,CAACK,IAAI,CAACF,OAAO,CAAC,CAACG,KAAK,CAACF,MAAM,CAC3C,CAAC;IACD,MAAMG,GAAG,GAAG,MAAMN,UAAU;IAC5B,OAAOV,WAAW,CAACgB,GAAG,CAAC;EACzB;AACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Hash } from './hash';
|
|
3
|
+
import { createHash } from 'crypto';
|
|
4
|
+
export class NodeHash extends Hash {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
var _this$options, _this$options$crypto;
|
|
7
|
+
super();
|
|
8
|
+
_defineProperty(this, "name", 'crypto-node');
|
|
9
|
+
_defineProperty(this, "options", void 0);
|
|
10
|
+
_defineProperty(this, "_algorithm", void 0);
|
|
11
|
+
_defineProperty(this, "_hash", void 0);
|
|
12
|
+
this.options = options;
|
|
13
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && (_this$options$crypto = _this$options.crypto) !== null && _this$options$crypto !== void 0 && _this$options$crypto.algorithm)) {
|
|
14
|
+
throw new Error(this.name);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async hash(input) {
|
|
18
|
+
var _this$options2, _this$options2$crypto, _this$options2$crypto2;
|
|
19
|
+
await this.preload();
|
|
20
|
+
const hash = createHash((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : (_this$options2$crypto = _this$options2.crypto) === null || _this$options2$crypto === void 0 ? void 0 : (_this$options2$crypto2 = _this$options2$crypto.algorithm) === null || _this$options2$crypto2 === void 0 ? void 0 : _this$options2$crypto2.toLowerCase());
|
|
21
|
+
const inputArray = new Uint8Array(input);
|
|
22
|
+
return hash.update(inputArray).digest('base64');
|
|
23
|
+
}
|
|
24
|
+
async *hashBatches(asyncIterator) {
|
|
25
|
+
var _this$options3, _this$options3$crypto, _this$options3$crypto2, _this$options4, _this$options4$crypto, _this$options4$crypto2;
|
|
26
|
+
await this.preload();
|
|
27
|
+
const hash = createHash((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : (_this$options3$crypto = _this$options3.crypto) === null || _this$options3$crypto === void 0 ? void 0 : (_this$options3$crypto2 = _this$options3$crypto.algorithm) === null || _this$options3$crypto2 === void 0 ? void 0 : _this$options3$crypto2.toLowerCase());
|
|
28
|
+
for await (const chunk of asyncIterator) {
|
|
29
|
+
const inputArray = new Uint8Array(chunk);
|
|
30
|
+
hash.update(inputArray);
|
|
31
|
+
yield chunk;
|
|
32
|
+
}
|
|
33
|
+
(_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : (_this$options4$crypto = _this$options4.crypto) === null || _this$options4$crypto === void 0 ? void 0 : (_this$options4$crypto2 = _this$options4$crypto.onEnd) === null || _this$options4$crypto2 === void 0 ? void 0 : _this$options4$crypto2.call(_this$options4$crypto, {
|
|
34
|
+
hash: hash.digest('base64')
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=node-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-hash.js","names":["Hash","createHash","NodeHash","constructor","options","_this$options","_this$options$crypto","_defineProperty","crypto","algorithm","Error","name","hash","input","_this$options2","_this$options2$crypto","_this$options2$crypto2","preload","toLowerCase","inputArray","Uint8Array","update","digest","hashBatches","asyncIterator","_this$options3","_this$options3$crypto","_this$options3$crypto2","_this$options4","_this$options4$crypto","_this$options4$crypto2","chunk","onEnd","call"],"sources":["../../../src/lib/node-hash.ts"],"sourcesContent":["// This dependency is too big, application must provide it\nimport {Hash} from './hash';\nimport {createHash} from 'crypto'; // Node.js builtin\n\ntype CryptoHashOptions = {\n crypto: {\n algorithm: string;\n onEnd?: (result: {hash: string}) => any;\n };\n};\n\n/**\n * Calculates Cryptographic Hash using Node.js crypto library\n * @deprecated Warning, experimental class\n */\nexport class NodeHash extends Hash {\n readonly name = 'crypto-node';\n\n options: CryptoHashOptions;\n // @ts-ignore\n private _algorithm;\n // @ts-ignore\n private _hash;\n\n constructor(options: CryptoHashOptions) {\n super();\n this.options = options;\n if (!this.options?.crypto?.algorithm) {\n throw new Error(this.name);\n }\n }\n\n /**\n * Atomic hash calculation\n * @returns base64 encoded hash\n */\n async hash(input: ArrayBuffer): Promise<string> {\n await this.preload();\n const hash = createHash(this.options?.crypto?.algorithm?.toLowerCase());\n const inputArray = new Uint8Array(input);\n return hash.update(inputArray).digest('base64');\n }\n\n async *hashBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n ): AsyncIterable<ArrayBuffer> {\n await this.preload();\n const hash = createHash(this.options?.crypto?.algorithm?.toLowerCase());\n for await (const chunk of asyncIterator) {\n // https://stackoverflow.com/questions/25567468/how-to-decrypt-an-arraybuffer\n const inputArray = new Uint8Array(chunk);\n hash.update(inputArray);\n yield chunk;\n }\n this.options?.crypto?.onEnd?.({hash: hash.digest('base64')});\n }\n}\n"],"mappings":";AACA,SAAQA,IAAI,QAAO,QAAQ;AAC3B,SAAQC,UAAU,QAAO,QAAQ;AAajC,OAAO,MAAMC,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AAA,GAAZD,cAAA,CAAcjB,MAAM,cAAAkB,qBAAA,wBAAAC,sBAAA,GAApBD,qBAAA,CAAsBjB,SAAS,cAAAkB,sBAAA,uBAA/BA,sBAAA,CAAiCT,WAAW,CAAC,CAAC,CAAC;IACvE,WAAW,MAAMa,KAAK,IAAIP,aAAa,EAAE;MAEvC,MAAML,UAAU,GAAG,IAAIC,UAAU,CAACW,KAAK,CAAC;MACxCnB,IAAI,CAACS,MAAM,CAACF,UAAU,CAAC;MACvB,MAAMY,KAAK;IACb;IACA,CAAAH,cAAA,OAAI,CAACxB,OAAO,cAAAwB,cAAA,wBAAAC,qBAAA,GAAZD,cAAA,CAAcpB,MAAM,cAAAqB,qBAAA,wBAAAC,sBAAA,GAApBD,qBAAA,CAAsBG,KAAK,cAAAF,sBAAA,uBAA3BA,sBAAA,CAAAG,IAAA,CAAAJ,qBAAA,EAA8B;MAACjB,IAAI,EAAEA,IAAI,CAACU,MAAM,CAAC,QAAQ;IAAC,CAAC,CAAC;EAC9D;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CryptoHash } from './crypto-hash';
|
|
2
|
+
export class SHA256Hash extends CryptoHash {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
super({
|
|
5
|
+
...options,
|
|
6
|
+
crypto: {
|
|
7
|
+
...options.crypto,
|
|
8
|
+
algorithm: 'SHA256'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=sha256-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256-hash.js","names":["CryptoHash","SHA256Hash","constructor","options","crypto","algorithm"],"sources":["../../../src/lib/sha256-hash.ts"],"sourcesContent":["//\nimport {CryptoHash} from './crypto-hash';\n\ntype CryptoHashOptions = {\n modules: {[moduleName: string]: any};\n crypto?: {\n onEnd?: (result: {hash: string}) => any;\n };\n};\n\n/**\n * A transform that calculates Cryptographic Hash\n */\nexport class SHA256Hash extends CryptoHash {\n constructor(options: CryptoHashOptions) {\n super({...options, crypto: {...options.crypto, algorithm: 'SHA256'}});\n }\n}\n"],"mappings":"AACA,SAAQA,UAAU,QAAO,eAAe;AAYxC,OAAO,MAAMC,UAAU,SAASD,UAAU,CAAC;EACzCE,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC;MAAC,GAAGA,OAAO;MAAEC,MAAM,EAAE;QAAC,GAAGD,OAAO,CAACC,MAAM;QAAEC,SAAS,EAAE;MAAQ;IAAC,CAAC,CAAC;EACvE;AACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function toBase64(string) {
|
|
2
|
+
string = "".concat(string);
|
|
3
|
+
for (let i = 0; i < string.length; i++) {
|
|
4
|
+
if (string.charCodeAt(i) > 255) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
let out = '';
|
|
9
|
+
for (let i = 0; i < string.length; i += 3) {
|
|
10
|
+
const groupsOfSix = [undefined, undefined, undefined, undefined];
|
|
11
|
+
groupsOfSix[0] = string.charCodeAt(i) >> 2;
|
|
12
|
+
groupsOfSix[1] = (string.charCodeAt(i) & 0x03) << 4;
|
|
13
|
+
if (string.length > i + 1) {
|
|
14
|
+
groupsOfSix[1] |= string.charCodeAt(i + 1) >> 4;
|
|
15
|
+
groupsOfSix[2] = (string.charCodeAt(i + 1) & 0x0f) << 2;
|
|
16
|
+
}
|
|
17
|
+
if (string.length > i + 2) {
|
|
18
|
+
groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6;
|
|
19
|
+
groupsOfSix[3] = string.charCodeAt(i + 2) & 0x3f;
|
|
20
|
+
}
|
|
21
|
+
for (let j = 0; j < groupsOfSix.length; j++) {
|
|
22
|
+
if (typeof groupsOfSix[j] === 'undefined') {
|
|
23
|
+
out += '=';
|
|
24
|
+
} else {
|
|
25
|
+
out += btoaLookup(groupsOfSix[j]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
function btoaLookup(idx) {
|
|
32
|
+
if (idx < 26) {
|
|
33
|
+
return String.fromCharCode(idx + 'A'.charCodeAt(0));
|
|
34
|
+
}
|
|
35
|
+
if (idx < 52) {
|
|
36
|
+
return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0));
|
|
37
|
+
}
|
|
38
|
+
if (idx < 62) {
|
|
39
|
+
return String.fromCharCode(idx - 52 + '0'.charCodeAt(0));
|
|
40
|
+
}
|
|
41
|
+
if (idx === 62) {
|
|
42
|
+
return '+';
|
|
43
|
+
}
|
|
44
|
+
if (idx === 63) {
|
|
45
|
+
return '/';
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=base64-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64-utils.js","names":["toBase64","string","concat","i","length","charCodeAt","out","groupsOfSix","undefined","j","btoaLookup","idx","String","fromCharCode"],"sources":["../../../../src/lib/utils/base64-utils.ts"],"sourcesContent":["/**\n * `btoa()` polyfill as defined by the HTML and Infra specs, which mostly just references\n * RFC 4648.\n */\nexport function toBase64(string: string): string | null {\n // String conversion as required by Web IDL.\n string = `${string}`;\n // \"The btoa() method must throw an \"InvalidCharacterError\" DOMException if\n // data contains any character whose code point is greater than U+00FF.\"\n for (let i = 0; i < string.length; i++) {\n if (string.charCodeAt(i) > 255) {\n return null;\n }\n }\n let out = '';\n for (let i = 0; i < string.length; i += 3) {\n /** @type {Array[4]} */\n const groupsOfSix: (number | undefined)[] = [undefined, undefined, undefined, undefined];\n groupsOfSix[0] = string.charCodeAt(i) >> 2;\n groupsOfSix[1] = (string.charCodeAt(i) & 0x03) << 4;\n if (string.length > i + 1) {\n groupsOfSix[1] |= string.charCodeAt(i + 1) >> 4;\n groupsOfSix[2] = (string.charCodeAt(i + 1) & 0x0f) << 2;\n }\n if (string.length > i + 2) {\n // @ts-expect-error\n groupsOfSix[2] |= string.charCodeAt(i + 2) >> 6;\n groupsOfSix[3] = string.charCodeAt(i + 2) & 0x3f;\n }\n for (let j = 0; j < groupsOfSix.length; j++) {\n if (typeof groupsOfSix[j] === 'undefined') {\n out += '=';\n } else {\n out += btoaLookup(groupsOfSix[j]);\n }\n }\n }\n return out;\n}\n\n/**\n * Lookup table for btoa(), which converts a six-bit number into the\n * corresponding ASCII character.\n */\nfunction btoaLookup(idx) {\n if (idx < 26) {\n return String.fromCharCode(idx + 'A'.charCodeAt(0));\n }\n if (idx < 52) {\n return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0));\n }\n if (idx < 62) {\n return String.fromCharCode(idx - 52 + '0'.charCodeAt(0));\n }\n if (idx === 62) {\n return '+';\n }\n if (idx === 63) {\n return '/';\n }\n // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the teststring.\n return undefined;\n}\n"],"mappings":"AAIA,OAAO,SAASA,QAAQA,CAACC,MAAc,EAAiB;EAEtDA,MAAM,MAAAC,MAAA,CAAMD,MAAM,CAAE;EAGpB,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACtC,IAAIF,MAAM,CAACI,UAAU,CAACF,CAAC,CAAC,GAAG,GAAG,EAAE;MAC9B,OAAO,IAAI;IACb;EACF;EACA,IAAIG,GAAG,GAAG,EAAE;EACZ,KAAK,IAAIH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAED,CAAC,IAAI,CAAC,EAAE;IAEzC,MAAMI,WAAmC,GAAG,CAACC,SAAS,EAAEA,SAAS,EAAEA,SAAS,EAAEA,SAAS,CAAC;IACxFD,WAAW,CAAC,CAAC,CAAC,GAAGN,MAAM,CAACI,UAAU,CAACF,CAAC,CAAC,IAAI,CAAC;IAC1CI,WAAW,CAAC,CAAC,CAAC,GAAG,CAACN,MAAM,CAACI,U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M,GAAG,GAAG,EAAE,EAAE;IACZ,OAAOC,MAAM,CAACC,YAAY,CAACF,GAAG,GAAG,EAAE,GAAG,GAAG,CAACN,UAAU,CAAC,CAAC,CAAC,CAAC;EAC1D;EACA,IAAIM,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,GAAG;EACZ;EACA,IAAIA,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,GAAG;EACZ;EAEA,OAAOH,SAAS;AAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toBase64 } from './base64-utils';
|
|
2
|
+
export function toHex(cipher) {
|
|
3
|
+
const hexString = cipher.toString(16);
|
|
4
|
+
return hexString === '0' ? "0".concat(hexString) : hexString;
|
|
5
|
+
}
|
|
6
|
+
export function hexToBase64(hexstring) {
|
|
7
|
+
if (hexstring.length % 2 !== 0) {
|
|
8
|
+
hexstring = "0".concat(hexstring);
|
|
9
|
+
}
|
|
10
|
+
const matches = hexstring.match(/\w{2}/g) || [];
|
|
11
|
+
const string = matches.map(a => String.fromCharCode(parseInt(a, 16))).join('');
|
|
12
|
+
return toBase64(string) || '';
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=digest-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-utils.js","names":["toBase64","toHex","cipher","hexString","toString","concat","hexToBase64","hexstring","length","matches","match","string","map","a","String","fromCharCode","parseInt","join"],"sources":["../../../../src/lib/utils/digest-utils.ts"],"sourcesContent":["import {toBase64} from './base64-utils';\n\n/**\n *\n */\nexport function toHex(cipher: number): string {\n const hexString = cipher.toString(16);\n return hexString === '0' ? `0${hexString}` : hexString;\n}\n\n/**\n * @see https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript\n */\nexport function hexToBase64(hexstring: string): string {\n // Add leading zero to keep even count of digits\n // eg. f85d741 => 0f85d741\n if (hexstring.length % 2 !== 0) {\n hexstring = `0${hexstring}`;\n }\n const matches = hexstring.match(/\\w{2}/g) || [];\n const string = matches.map((a) => String.fromCharCode(parseInt(a, 16))).join('');\n // TODO - define how to handle failures\n return toBase64(string) || '';\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,gBAAgB;AAKvC,OAAO,SAASC,KAAKA,CAACC,MAAc,EAAU;EAC5C,MAAMC,SAAS,GAAGD,MAAM,CAACE,QAAQ,CAAC,EAAE,CAAC;EACrC,OAAOD,SAAS,KAAK,GAAG,OAAAE,MAAA,CAAOF,SAAS,IAAKA,SAAS;AACxD;AAKA,OAAO,SAASG,WAAWA,CAACC,SAAiB,EAAU;EAGrD,IAAIA,SAAS,CAACC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;IAC9BD,SAAS,OAAAF,MAAA,CAAOE,SAAS,CAAE;EAC7B;EACA,MAAME,OAAO,GAAGF,SAAS,CAACG,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;EAC/C,MAAMC,MAAM,GAAGF,OAAO,CAACG,GAAG,CAAEC,CAAC,IAAKC,MAAM,CAACC,YAAY,CAACC,QAAQ,CAACH,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAACI,IAAI,CAAC,EAAE,CAAC;EAEhF,OAAOjB,QAAQ,CAACW,MAAM,CAAC,IAAI,EAAE;AAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["export type CryptoHashOptions = {\n modules?: {[moduleName: string]: any};\n crypto?: {\n algorithm;\n onEnd?;\n };\n};\n"],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {CryptoHashOptions} from '../lib/crypto-hash';
|
|
2
|
+
import {createWorker} from '@loaders.gl/worker-utils';
|
|
3
|
+
import {CryptoHash} from '../lib/crypto-hash';
|
|
4
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
+
import * as CryptoJS from 'crypto-js';
|
|
6
|
+
|
|
7
|
+
// Assuming we can bundle as module
|
|
8
|
+
export {CryptoHash};
|
|
9
|
+
|
|
10
|
+
createWorker(async (data, options) => {
|
|
11
|
+
options = {
|
|
12
|
+
...options,
|
|
13
|
+
modules: {CryptoJS}
|
|
14
|
+
};
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
const {operation} = options;
|
|
17
|
+
|
|
18
|
+
switch (operation) {
|
|
19
|
+
case 'crc32':
|
|
20
|
+
return await new CryptoHash(options).hash(data);
|
|
21
|
+
case 'crc32c':
|
|
22
|
+
return await new CryptoHash(options).hash(data);
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`invalid option: ${operation}`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createWorker } from '@loaders.gl/worker-utils';
|
|
2
|
+
import { CRC32Hash } from '../lib/crc32-hash';
|
|
3
|
+
import { CRC32CHash } from '../lib/crc32c-hash';
|
|
4
|
+
import { MD5Hash } from '../lib/md5-hash';
|
|
5
|
+
export { CRC32Hash, CRC32CHash };
|
|
6
|
+
createWorker(async function (data) {
|
|
7
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8
|
+
const {
|
|
9
|
+
operation
|
|
10
|
+
} = options;
|
|
11
|
+
switch (operation) {
|
|
12
|
+
case 'crc32':
|
|
13
|
+
return await new CRC32Hash(options).hash(data);
|
|
14
|
+
case 'crc32c':
|
|
15
|
+
return await new CRC32CHash(options).hash(data);
|
|
16
|
+
case 'md5':
|
|
17
|
+
return await new MD5Hash(options).hash(data);
|
|
18
|
+
default:
|
|
19
|
+
throw new Error("invalid option: ".concat(operation));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","names":["createWorker","CRC32Hash","CRC32CHash","MD5Hash","data","options","arguments","length","undefined","operation","hash","Error","concat"],"sources":["../../../src/workers/worker.ts"],"sourcesContent":["import {createWorker} from '@loaders.gl/worker-utils';\nimport {CRC32Hash} from '../lib/crc32-hash';\nimport {CRC32CHash} from '../lib/crc32c-hash';\nimport {MD5Hash} from '../lib/md5-hash';\n\n// Assuming we can bundle as module\nexport {CRC32Hash, CRC32CHash};\n\ncreateWorker(async (data, options = {}) => {\n // @ts-ignore\n const {operation} = options;\n\n switch (operation) {\n case 'crc32':\n return await new CRC32Hash(options).hash(data);\n case 'crc32c':\n return await new CRC32CHash(options).hash(data);\n case 'md5':\n return await new MD5Hash(options).hash(data);\n default:\n throw new Error(`invalid option: ${operation}`);\n }\n});\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,0BAA0B;AACrD,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,UAAU,QAAO,oBAAoB;AAC7C,SAAQC,OAAO,QAAO,iBAAiB;AAGvC,SAAQF,SAAS,EAAEC,UAAU;AAE7BF,YAAY,CAAC,gBAAOI,IAAI,EAAmB;EAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEpC,MAAM;IAACG;EAAS,CAAC,GAAGJ,OAAO;EAE3B,QAAQI,SAAS;IACf,KAAK,OAAO;MACV,OAAO,MAAM,IAAIR,SAAS,CAACI,OAAO,CAAC,CAACK,IAAI,CAACN,IAAI,CAAC;IAChD,KAAK,QAAQ;MACX,OAAO,MAAM,IAAIF,UAAU,CAACG,OAAO,CAAC,CAACK,IAAI,CAACN,IAAI,CAAC;IACjD,KAAK,KAAK;MACR,OAAO,MAAM,IAAID,OAAO,CAACE,OAAO,CAAC,CAACK,IAAI,CAACN,IAAI,CAAC;IAC9C;MACE,MAAM,IAAIO,KAAK,oBAAAC,MAAA,CAAoBH,SAAS,CAAE,CAAC;EACnD;AACF,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// import type {WorkerObject} from '@loaders.gl/worker-utils';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CryptoJSWorker = exports.CryptoWorker = exports._toHex = exports._hexToBase64 = exports.NodeHash = exports.CryptoHash = exports.SHA256Hash = exports.MD5Hash = exports.CRC32CHash = exports.CRC32Hash = void 0;
|
|
5
|
+
var crc32_hash_1 = require("./lib/crc32-hash");
|
|
6
|
+
Object.defineProperty(exports, "CRC32Hash", { enumerable: true, get: function () { return crc32_hash_1.CRC32Hash; } });
|
|
7
|
+
var crc32c_hash_1 = require("./lib/crc32c-hash");
|
|
8
|
+
Object.defineProperty(exports, "CRC32CHash", { enumerable: true, get: function () { return crc32c_hash_1.CRC32CHash; } });
|
|
9
|
+
var md5_hash_1 = require("./lib/md5-hash");
|
|
10
|
+
Object.defineProperty(exports, "MD5Hash", { enumerable: true, get: function () { return md5_hash_1.MD5Hash; } });
|
|
11
|
+
var sha256_hash_1 = require("./lib/sha256-hash");
|
|
12
|
+
Object.defineProperty(exports, "SHA256Hash", { enumerable: true, get: function () { return sha256_hash_1.SHA256Hash; } });
|
|
13
|
+
var crypto_hash_1 = require("./lib/crypto-hash");
|
|
14
|
+
Object.defineProperty(exports, "CryptoHash", { enumerable: true, get: function () { return crypto_hash_1.CryptoHash; } });
|
|
15
|
+
var node_hash_1 = require("./lib/node-hash");
|
|
16
|
+
Object.defineProperty(exports, "NodeHash", { enumerable: true, get: function () { return node_hash_1.NodeHash; } });
|
|
17
|
+
var digest_utils_1 = require("./lib/utils/digest-utils");
|
|
18
|
+
Object.defineProperty(exports, "_hexToBase64", { enumerable: true, get: function () { return digest_utils_1.hexToBase64; } });
|
|
19
|
+
Object.defineProperty(exports, "_toHex", { enumerable: true, get: function () { return digest_utils_1.toHex; } });
|
|
20
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
21
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
22
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
23
|
+
/**
|
|
24
|
+
* Small, fast worker for CRC32, CRC32c and MD5 Hashes
|
|
25
|
+
*/
|
|
26
|
+
exports.CryptoWorker = {
|
|
27
|
+
id: 'crypto',
|
|
28
|
+
name: 'CRC32, CRC32c and MD5 Hashes',
|
|
29
|
+
module: 'crypto',
|
|
30
|
+
version: VERSION,
|
|
31
|
+
options: {
|
|
32
|
+
crypto: {}
|
|
33
|
+
}
|
|
17
34
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Large worker for full complement of Cryptographic Hashes
|
|
37
|
+
* bundles the full crypto.js library
|
|
38
|
+
*/
|
|
39
|
+
exports.CryptoJSWorker = {
|
|
40
|
+
id: 'cryptojs',
|
|
41
|
+
name: 'Cryptographic Hashes',
|
|
42
|
+
module: 'crypto',
|
|
43
|
+
version: VERSION,
|
|
44
|
+
options: {
|
|
45
|
+
cryptojs: {}
|
|
46
|
+
}
|
|
26
47
|
};
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// Inspired by https://gist.github.com/wqli78/1330293/6d85cc967f32cccfcbad94ae7d088a3dcfc14bd9
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the CRC32 checksum of a string.
|
|
6
|
+
*/
|
|
7
|
+
class CRC32 {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.crc = ~0;
|
|
10
|
+
}
|
|
11
|
+
update(arrayBuffer) {
|
|
12
|
+
const CRC32_TABLE = getCRC32Table();
|
|
13
|
+
const byteArray = new Uint8Array(arrayBuffer);
|
|
14
|
+
for (let i = 0; i < byteArray.byteLength; i++) {
|
|
15
|
+
this.crc = (this.crc >>> 8) ^ CRC32_TABLE[(this.crc ^ byteArray[i]) & 0xff];
|
|
16
|
+
// strings: crc = (crc >>> 8) ^ CRC32TAB[(crc ^ str.charCodeAt(i)) & 0xff];
|
|
17
|
+
}
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
finalize() {
|
|
21
|
+
this.crc = Math.abs(this.crc ^ -1);
|
|
22
|
+
return this.crc;
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
finalize() {
|
|
21
|
-
this.crc = Math.abs(this.crc ^ -1);
|
|
22
|
-
return this.crc;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
24
|
}
|
|
25
|
+
exports.default = CRC32;
|
|
26
|
+
// Note: Using a typed array here doubles the speed of the cipher
|
|
26
27
|
const CRC32TAB = Uint32Array.of(0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d);
|
|
27
|
-
|
|
28
28
|
function getCRC32Table() {
|
|
29
|
-
|
|
29
|
+
return CRC32TAB;
|
|
30
30
|
}
|
|
31
|
-
//# sourceMappingURL=crc32.js.map
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// From: https://gist.github.com/wqli78/1330293/6d85cc967f32cccfcbad94ae7d088a3dcfc14bd9
|
|
3
|
+
// CRC32 doesn't appear to be supported natively by crypto-js
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// import {toBuffer} from '@loaders.gl/loader-utils';
|
|
6
|
+
// import {calculate as sse4calculate} from 'sse4_crc32';
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the CRC32C checksum of a string.
|
|
9
|
+
*/
|
|
10
|
+
class CRC32C {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.crc = ~0;
|
|
14
|
+
}
|
|
15
|
+
update(arrayBuffer) {
|
|
16
|
+
const byteArray = new Uint8Array(arrayBuffer);
|
|
17
|
+
const CRC32_TABLE = getCRC32Table();
|
|
18
|
+
for (let i = 0; i < byteArray.length; i++) {
|
|
19
|
+
this.crc = CRC32_TABLE[(this.crc ^ byteArray[i]) & 0xff] ^ (this.crc >>> 8);
|
|
20
|
+
}
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
finalize() {
|
|
24
|
+
this.crc = (this.crc ^ -1) >>> 0;
|
|
25
|
+
return this.crc;
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
finalize() {
|
|
24
|
-
this.crc = (this.crc ^ -1) >>> 0;
|
|
25
|
-
return this.crc;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
27
|
}
|
|
28
|
+
exports.default = CRC32C;
|
|
29
|
+
/**
|
|
30
|
+
* This code is a manual javascript translation of c code generated by
|
|
31
|
+
* pycrc 0.7.1 (http://www.tty1.net/pycrc/). Command line used:
|
|
32
|
+
* './pycrc.py --model=crc-32c --generate c --algorithm=table-driven'
|
|
33
|
+
*/
|
|
34
|
+
// Note: Using a typed array here doubles the speed of the cipher
|
|
29
35
|
const CRC32C_TABLE = Int32Array.of(0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351);
|
|
30
|
-
|
|
31
36
|
function getCRC32Table() {
|
|
32
|
-
|
|
37
|
+
return CRC32C_TABLE;
|
|
33
38
|
}
|
|
34
|
-
//# sourceMappingURL=crc32c.js.map
|