@fastcar/core 0.2.43 → 0.2.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/package.json
CHANGED
|
@@ -96,7 +96,9 @@ export default function ValidForm(target: any, methodName: string, descriptor: P
|
|
|
96
96
|
if (rule.required) {
|
|
97
97
|
throwErrMsg(rule, prop, rule.nullMessage);
|
|
98
98
|
} else {
|
|
99
|
-
|
|
99
|
+
if(TypeUtil.isObject(currObj) && !Reflect.has(currObj, prop)) {
|
|
100
|
+
delFormValue(currObj, prop);
|
|
101
|
+
}
|
|
100
102
|
}
|
|
101
103
|
} else {
|
|
102
104
|
//进行类型判断并赋值
|
package/src/utils/CryptoUtil.ts
CHANGED
|
@@ -74,10 +74,7 @@ export default class CryptoUtil {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
static sha256Encode(text: string, serect: string = crypto.randomBytes(32).toString("hex"), encoding: BinaryToTextEncoding = "base64"): { salt: string; msg: string } {
|
|
77
|
-
let msg = crypto
|
|
78
|
-
.createHmac("sha256", serect)
|
|
79
|
-
.update(text)
|
|
80
|
-
.digest(encoding);
|
|
77
|
+
let msg = crypto.createHmac("sha256", serect).update(text).digest(encoding);
|
|
81
78
|
|
|
82
79
|
return {
|
|
83
80
|
salt: serect,
|
|
@@ -86,10 +83,7 @@ export default class CryptoUtil {
|
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
static sha256EncodeContent(str: string, encoding: BinaryToTextEncoding = "base64"): string {
|
|
89
|
-
let msg = crypto
|
|
90
|
-
.createHash("sha256")
|
|
91
|
-
.update(str)
|
|
92
|
-
.digest(encoding);
|
|
86
|
+
let msg = crypto.createHash("sha256").update(str).digest(encoding);
|
|
93
87
|
|
|
94
88
|
return msg;
|
|
95
89
|
}
|
|
@@ -103,4 +97,15 @@ export default class CryptoUtil {
|
|
|
103
97
|
static getHashStr(num: number = 16): string {
|
|
104
98
|
return crypto.randomBytes(num).toString("hex");
|
|
105
99
|
}
|
|
100
|
+
|
|
101
|
+
//根据给定的字符串返回hash值按照追加的原则
|
|
102
|
+
static getHashStrByLength(serect: string, num: number): string {
|
|
103
|
+
let list = crypto.createHash("md5").update(serect).digest().toString("hex");
|
|
104
|
+
|
|
105
|
+
while (list.length < num) {
|
|
106
|
+
list = list.repeat(num - list.length);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return list.substring(0, num);
|
|
110
|
+
}
|
|
106
111
|
}
|
|
@@ -85,7 +85,9 @@ function ValidForm(target, methodName, descriptor) {
|
|
|
85
85
|
throwErrMsg(rule, prop, rule.nullMessage);
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
|
|
88
|
+
if (utils_1.TypeUtil.isObject(currObj) && !Reflect.has(currObj, prop)) {
|
|
89
|
+
delFormValue(currObj, prop);
|
|
90
|
+
}
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
else {
|
|
@@ -57,20 +57,14 @@ class CryptoUtil {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
static sha256Encode(text, serect = crypto.randomBytes(32).toString("hex"), encoding = "base64") {
|
|
60
|
-
let msg = crypto
|
|
61
|
-
.createHmac("sha256", serect)
|
|
62
|
-
.update(text)
|
|
63
|
-
.digest(encoding);
|
|
60
|
+
let msg = crypto.createHmac("sha256", serect).update(text).digest(encoding);
|
|
64
61
|
return {
|
|
65
62
|
salt: serect,
|
|
66
63
|
msg: msg,
|
|
67
64
|
};
|
|
68
65
|
}
|
|
69
66
|
static sha256EncodeContent(str, encoding = "base64") {
|
|
70
|
-
let msg = crypto
|
|
71
|
-
.createHash("sha256")
|
|
72
|
-
.update(str)
|
|
73
|
-
.digest(encoding);
|
|
67
|
+
let msg = crypto.createHash("sha256").update(str).digest(encoding);
|
|
74
68
|
return msg;
|
|
75
69
|
}
|
|
76
70
|
static sha256Very(msg, serect, encodeMsg, encoding = "base64") {
|
|
@@ -80,5 +74,13 @@ class CryptoUtil {
|
|
|
80
74
|
static getHashStr(num = 16) {
|
|
81
75
|
return crypto.randomBytes(num).toString("hex");
|
|
82
76
|
}
|
|
77
|
+
//根据给定的字符串返回hash值按照追加的原则
|
|
78
|
+
static getHashStrByLength(serect, num) {
|
|
79
|
+
let list = crypto.createHash("md5").update(serect).digest().toString("hex");
|
|
80
|
+
while (list.length < num) {
|
|
81
|
+
list = list.repeat(num - list.length);
|
|
82
|
+
}
|
|
83
|
+
return list.substring(0, num);
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
exports.default = CryptoUtil;
|
package/utils.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ export class CryptoUtil {
|
|
|
57
57
|
static sha256Very(msg: string, serect: string, encodeMsg: string, encoding?: BinaryToTextEncoding): boolean;
|
|
58
58
|
|
|
59
59
|
static getHashStr(num?: number): string;
|
|
60
|
+
|
|
61
|
+
static getHashStrByLength(serect: string, num: number): string;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
export class FileUtil {
|