light-h5-core-lib 2.7.2 → 2.7.4
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/common/util/CryptUtil.js +16 -20
- package/package.json +2 -2
- package/type/index.d.ts +4 -1
package/common/util/CryptUtil.js
CHANGED
|
@@ -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
|
|
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,26 @@ var CryptUtil = /** @class */ (function () {
|
|
|
13
15
|
//#region AES-256 ECB
|
|
14
16
|
/** 加密函数AES-256 ECB */
|
|
15
17
|
CryptUtil.encryptAes = function (plainText, key) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 encrypted = crypto_es_1.default.AES.encrypt(crypto_es_1.default.enc.Utf8.parse(plainText), key, {
|
|
19
|
+
mode: crypto_es_1.default.mode.ECB,
|
|
20
|
+
padding: crypto_es_1.default.pad.Pkcs7,
|
|
22
21
|
});
|
|
23
|
-
// 将加密结果转换为 base64 编码的字符串
|
|
24
22
|
return encrypted.toString();
|
|
25
23
|
};
|
|
26
24
|
/**解密函数AES-256 ECB*/
|
|
27
25
|
CryptUtil.decryptAes = function (cipherText, key) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var decrypted = crypto_ts_1.AES.decrypt(cipherText, keyBytes, {
|
|
32
|
-
mode: crypto_ts_1.mode.ECB,
|
|
33
|
-
padding: crypto_ts_1.pad.PKCS7,
|
|
26
|
+
var decrypted = crypto_es_1.default.AES.decrypt(cipherText, key, {
|
|
27
|
+
mode: crypto_es_1.default.mode.ECB,
|
|
28
|
+
padding: crypto_es_1.default.pad.Pkcs7,
|
|
34
29
|
});
|
|
35
|
-
|
|
36
|
-
return decrypted.toString(crypto_ts_1.enc.Utf8);
|
|
30
|
+
return crypto_es_1.default.enc.Utf8.stringify(decrypted);
|
|
37
31
|
};
|
|
38
32
|
//#endregion
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
/**
|
|
34
|
+
* MD5
|
|
35
|
+
*/
|
|
36
|
+
CryptUtil.md5 = function (text) {
|
|
37
|
+
return crypto_es_1.default.MD5(text).toString();
|
|
42
38
|
};
|
|
43
39
|
return CryptUtil;
|
|
44
40
|
}());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "light-h5-core-lib",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.4",
|
|
4
4
|
"description": "light core lib",
|
|
5
5
|
"main": "./LightCore.js",
|
|
6
6
|
"types": "./type/index.d.ts",
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
"author": "Aonaufly",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"crypto-
|
|
18
|
+
"crypto-es": "^2.1.0"
|
|
19
19
|
}
|
|
20
20
|
}
|
package/type/index.d.ts
CHANGED
|
@@ -203,7 +203,10 @@ export declare class CryptUtil {
|
|
|
203
203
|
static encryptAes(plainText: string, key: string): string;
|
|
204
204
|
/**解密函数AES-256 ECB*/
|
|
205
205
|
static decryptAes(cipherText: string, key: string): string;
|
|
206
|
-
|
|
206
|
+
/**
|
|
207
|
+
* MD5
|
|
208
|
+
*/
|
|
209
|
+
static md5(text: string): string;
|
|
207
210
|
}
|
|
208
211
|
export declare class MD5 extends BaseSingleton<MD5> {
|
|
209
212
|
private hexcase;
|