fast-cocos 1.1.7 → 1.1.8

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.
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.XOR_VERSION = exports.DEFAULT_IMAGE_EXTS = exports.DEFAULT_KEY = exports.DEFAULT_SIGN = void 0;
7
- exports.xorTransform = xorTransform;
8
7
  exports.encryptFile = encryptFile;
9
8
  exports.decryptFile = decryptFile;
10
9
  exports.batchProcess = batchProcess;
@@ -19,18 +18,6 @@ exports.DEFAULT_KEY = "Xk9#mQ2$vL5@nR8w";
19
18
  /** 默认参与批量处理的图片扩展名 */
20
19
  exports.DEFAULT_IMAGE_EXTS = [".png", ".jpg", ".jpeg", ".webp", ".bmp"];
21
20
  exports.XOR_VERSION = "1.0.0";
22
- /**
23
- * XOR 加密/解密(对称)
24
- */
25
- function xorTransform(opts) {
26
- const { data, key } = opts;
27
- const result = Buffer.alloc(data.length);
28
- const keyLen = key.length;
29
- for (let i = 0; i < data.length; i++) {
30
- result[i] = data[i] ^ key.charCodeAt(i % keyLen);
31
- }
32
- return result;
33
- }
34
21
  function xor(data, key) {
35
22
  let result = "";
36
23
  for (let i = 0; i < data.length; i++) {
@@ -98,7 +85,7 @@ function decryptFile(opts) {
98
85
  console.info("\x1b[31m%s\x1b[0m", `跳过(签名不匹配): ${opts.inputPath}`);
99
86
  return false;
100
87
  }
101
- const encrypted = encryptedData.slice(finalSign.length);
88
+ const encrypted = encryptedData.slice(finalSign.length, encryptedData.length);
102
89
  const decrypted = xor(encrypted, finalKey);
103
90
  fs_1.default.writeFileSync(destPath, decrypted, { encoding: "binary" });
104
91
  console.info("\x1b[32m%s\x1b[0m", `解密: ${opts.inputPath} -> ${destPath} [sign:${finalSign}, key:${finalKey.substring(0, 4)}...]`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-cocos",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "scripts": {
5
5
  "clean": "rm -rf dist",
6
6
  "start": "node ./dist/index.js",