@lcap/nasl-utils 3.9.0-beta.44 → 3.9.0-beta.45

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/out/hash.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  *
3
3
  * @param 文件内容 content
4
- * @returns MD5 hash8位
4
+ * @returns cyrb64 hash,取前 8
5
5
  */
6
- export declare function genHash(content: string): string;
6
+ export declare const genHash: (str: string) => string;
7
+ export default genHash;
7
8
  //# sourceMappingURL=hash.d.ts.map
package/out/hash.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,UAGtC"}
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AA8BA;;;;GAIG;AAEH,eAAO,MAAM,OAAO,QAAU,MAAM,WAAmC,CAAC;AAExE,eAAe,OAAO,CAAC"}
package/out/hash.js CHANGED
@@ -1,38 +1,39 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.genHash = void 0;
27
- const crypto = __importStar(require("crypto"));
4
+ // cyrb53 (c) 2018 bryc (github.com/bryc). License: Public domain. Attribution appreciated.
5
+ // A fast and simple 64-bit (or 53-bit) string hash function with decent collision resistance.
6
+ // Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
7
+ // See https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript/52171480#52171480
8
+ // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
9
+ const cyrb64 = (str, seed = 0) => {
10
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
11
+ for (let i = 0, ch; i < str.length; i++) {
12
+ ch = str.charCodeAt(i);
13
+ h1 = Math.imul(h1 ^ ch, 2654435761);
14
+ h2 = Math.imul(h2 ^ ch, 1597334677);
15
+ }
16
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
17
+ h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
18
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
19
+ h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
20
+ // For a single 53-bit numeric return value we could return
21
+ // 4294967296 * (2097151 & h2) + (h1 >>> 0);
22
+ // but we instead return the full 64-bit value:
23
+ return [h2 >>> 0, h1 >>> 0];
24
+ };
25
+ // An improved, *insecure* 64-bit hash that's short, fast, and has no dependencies.
26
+ // Output is always 14 characters.
27
+ const cyrb64Hash = (str, seed = 0) => {
28
+ const [h2, h1] = cyrb64(str, seed);
29
+ return h2.toString(36).padStart(7, '0') + h1.toString(36).padStart(7, '0');
30
+ };
28
31
  /**
29
32
  *
30
33
  * @param 文件内容 content
31
- * @returns MD5 hash8位
34
+ * @returns cyrb64 hash,取前 8
32
35
  */
33
- function genHash(content) {
34
- const hash = crypto.createHash('md5').update(content, 'utf8').digest('hex');
35
- return hash.slice(0, 8);
36
- }
36
+ const genHash = (str) => cyrb64Hash(str, 0).slice(0, 8);
37
37
  exports.genHash = genHash;
38
+ exports.default = exports.genHash;
38
39
  //# sourceMappingURL=hash.js.map
package/out/hash.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAEjC;;;;GAIG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC;AAHD,0BAGC"}
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC3F,8FAA8F;AAC9F,2EAA2E;AAC3E,8GAA8G;AAC9G,yEAAyE;AACzE,MAAM,MAAM,GAAG,CAAC,GAAY,EAAE,IAAI,GAAG,CAAC,EAAE,EAAE;IACxC,IAAI,EAAE,GAAG,UAAU,GAAG,IAAI,EAAE,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC;IACnD,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACvB,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACpC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GA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CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcap/nasl-utils",
3
3
  "description": "NetEase Application Specific Language",
4
- "version": "3.9.0-beta.44",
4
+ "version": "3.9.0-beta.45",
5
5
  "author": "Forrest <rainforest92@126.com>",
6
6
  "main": "./out",
7
7
  "types": "./out",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "uuid": "8.3.2",
26
- "@lcap/nasl-types": "3.9.0-beta.44"
26
+ "@lcap/nasl-types": "3.9.0-beta.45"
27
27
  },
28
28
  "scripts": {
29
29
  "clear": "rimraf ./out",