light-h5-core-lib 2.7.2 → 2.7.5

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/LightCore.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CryptUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.PoolObj = void 0;
3
+ exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.PoolObj = void 0;
4
4
  var PoolObj_1 = require("./pool/PoolObj");
5
5
  Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
6
6
  var BaseSingleton_1 = require("./common/base/BaseSingleton");
@@ -19,8 +19,6 @@ var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
19
19
  Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
20
20
  var BeizerUtil_1 = require("./common/util/BeizerUtil");
21
21
  Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
22
- var CryptUtil_1 = require("./common/util/CryptUtil");
23
- Object.defineProperty(exports, "CryptUtil", { enumerable: true, get: function () { return CryptUtil_1.CryptUtil; } });
24
22
  var MD5_1 = require("./common/md5/MD5");
25
23
  Object.defineProperty(exports, "MD5", { enumerable: true, get: function () { return MD5_1.MD5; } });
26
24
  module.exports = {
@@ -34,5 +32,4 @@ module.exports = {
34
32
  StringUtil: StringUtil_1.StringUtil,
35
33
  UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
36
34
  BeizerUtil: BeizerUtil_1.BeizerUtil,
37
- CryptUtil: CryptUtil_1.CryptUtil,
38
35
  };
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.CryptUtil = void 0;
4
- var crypto_ts_1 = require("crypto-ts");
5
- var MD5_1 = require("../md5/MD5");
7
+ var crypto_es_1 = __importDefault(require("crypto-es"));
6
8
  /**
7
9
  * 加解密工具
8
10
  * @author Aonaufly
@@ -13,32 +15,28 @@ var CryptUtil = /** @class */ (function () {
13
15
  //#region AES-256 ECB
14
16
  /** 加密函数AES-256 ECB */
15
17
  CryptUtil.encryptAes = function (plainText, key) {
16
- // 将密钥转换为 CryptoJS 格式的字节数组
17
- var keyBytes = crypto_ts_1.enc.Utf8.parse(key);
18
- // 使用 AES 加密,ECB 模式,Pkcs7 填充
19
- var encrypted = crypto_ts_1.AES.encrypt(plainText, keyBytes, {
20
- mode: crypto_ts_1.mode.ECB,
21
- padding: crypto_ts_1.pad.PKCS7,
18
+ var keyBytes = crypto_es_1.default.enc.Utf8.parse(key);
19
+ var encrypted = crypto_es_1.default.AES.encrypt(crypto_es_1.default.enc.Utf8.parse(plainText), keyBytes, {
20
+ mode: crypto_es_1.default.mode.ECB,
21
+ padding: crypto_es_1.default.pad.Pkcs7,
22
22
  });
23
- // 将加密结果转换为 base64 编码的字符串
24
23
  return encrypted.toString();
25
24
  };
26
25
  /**解密函数AES-256 ECB*/
27
26
  CryptUtil.decryptAes = function (cipherText, key) {
28
- // 将密钥转换为 CryptoJS 格式的字节数组
29
- var keyBytes = crypto_ts_1.enc.Utf8.parse(key);
30
- // 使用 AES 解密,ECB 模式,Pkcs7 填充
31
- var decrypted = crypto_ts_1.AES.decrypt(cipherText, keyBytes, {
32
- mode: crypto_ts_1.mode.ECB,
33
- padding: crypto_ts_1.pad.PKCS7,
27
+ var keyBytes = crypto_es_1.default.enc.Utf8.parse(key);
28
+ var decrypted = crypto_es_1.default.AES.decrypt(cipherText, keyBytes, {
29
+ mode: crypto_es_1.default.mode.ECB,
30
+ padding: crypto_es_1.default.pad.Pkcs7,
34
31
  });
35
- // 将解密结果转换为 UTF-8 编码的字符串
36
- return decrypted.toString(crypto_ts_1.enc.Utf8);
32
+ return crypto_es_1.default.enc.Utf8.stringify(decrypted);
37
33
  };
38
34
  //#endregion
39
- // MD5 哈希函数
40
- CryptUtil.md5 = function (input) {
41
- return MD5_1.MD5.getInstance(MD5_1.MD5).hex_md5(input);
35
+ /**
36
+ * MD5
37
+ */
38
+ CryptUtil.md5 = function (text) {
39
+ return crypto_es_1.default.MD5(text).toString();
42
40
  };
43
41
  return CryptUtil;
44
42
  }());
@@ -9,7 +9,7 @@ var RandomNumUtil = /** @class */ (function () {
9
9
  function RandomNumUtil() {
10
10
  }
11
11
  /**
12
- * 获取一定方位的随机整数
12
+ * 获取一定范围的随机整数
13
13
  *
14
14
  * <b>( min ≤ r ≤ max )</b>
15
15
  *
@@ -35,6 +35,20 @@ var RandomNumUtil = /** @class */ (function () {
35
35
  return isInt ? min : Math.round(min);
36
36
  }
37
37
  };
38
+ /**
39
+ * 打乱数组
40
+ */
41
+ RandomNumUtil.shuffleSort = function (arr) {
42
+ var n = arr.length;
43
+ var index;
44
+ var temp;
45
+ while (n--) {
46
+ index = Math.floor(Math.random() * n);
47
+ temp = arr[index];
48
+ arr[index] = arr[n];
49
+ arr[n] = temp;
50
+ }
51
+ };
38
52
  return RandomNumUtil;
39
53
  }());
40
54
  exports.RandomNumUtil = RandomNumUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "light-h5-core-lib",
3
- "version": "2.7.2",
3
+ "version": "2.7.5",
4
4
  "description": "light core lib",
5
5
  "main": "./LightCore.js",
6
6
  "types": "./type/index.d.ts",
@@ -14,7 +14,5 @@
14
14
  ],
15
15
  "author": "Aonaufly",
16
16
  "license": "ISC",
17
- "dependencies": {
18
- "crypto-ts": "^1.0.2"
19
- }
17
+ "dependencies": {}
20
18
  }
package/type/index.d.ts CHANGED
@@ -125,7 +125,7 @@ export declare class FloatDigitUtil {
125
125
  */
126
126
  export declare class RandomNumUtil {
127
127
  /**
128
- * 获取一定方位的随机整数
128
+ * 获取一定范围的随机整数
129
129
  *
130
130
  * <b>( min ≤ r ≤ max )</b>
131
131
  *
@@ -134,6 +134,10 @@ export declare class RandomNumUtil {
134
134
  * @param isInt 是否返回整数
135
135
  */
136
136
  static randomNumBoth(min: number, max: number, isInt?: boolean): number;
137
+ /**
138
+ * 打乱数组
139
+ */
140
+ static shuffleSort<T>(arr: T[]): void;
137
141
  }
138
142
  /**
139
143
  * 字符串工具
@@ -194,17 +198,6 @@ export declare class BeizerUtil {
194
198
  }[], precision?: number): number;
195
199
  private static getBezierPoint;
196
200
  }
197
- /**
198
- * 加解密工具
199
- * @author Aonaufly
200
- */
201
- export declare class CryptUtil {
202
- /** 加密函数AES-256 ECB */
203
- static encryptAes(plainText: string, key: string): string;
204
- /**解密函数AES-256 ECB*/
205
- static decryptAes(cipherText: string, key: string): string;
206
- static md5(input: string): string;
207
- }
208
201
  export declare class MD5 extends BaseSingleton<MD5> {
209
202
  private hexcase;
210
203
  private b64pad;