Skip to content

Commit 1c2afb6

Browse files
committed
EHN: Reuse existing logic to cover out duplication
1 parent e2ab6fc commit 1c2afb6

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

package/app.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,21 @@ const encrypta = (st: string, salt: string, d = 1) => {
1414
};
1515

1616
export const encrypt = (
17-
param: Object | string | number | any[],
18-
salt: string,
19-
d = 1
17+
param: Object | string | number | any[],
18+
salt: string,
19+
d = 1
2020
) => {
21-
const hashSalt: number = hashFun(salt.trim().substring(0, 20));
22-
return JSON.stringify(param)
23-
.split('')
24-
.map((c, i) =>
25-
String.fromCharCode(c.charCodeAt(0) + configNum(hashSalt, i) * d)
26-
)
27-
.join('')
28-
.replace(/\\/g, 'blacard')
29-
.replace(/\//g, 'danger')
30-
.replace(/"/g, 'killer')
31-
.replace(/'/g, 'terror')
32-
.replace(/ /g, 'blankart')
33-
.replace(/{/g, 'alpha')
34-
.replace(/}/g, 'mega')
35-
.replace(/`/g, 'omega');
21+
return encrypta(JSON.stringify(param), salt, d)
22+
.replace(/\\/g, 'blacard')
23+
.replace(/\//g, 'danger')
24+
.replace(/"/g, 'killer')
25+
.replace(/'/g, 'terror')
26+
.replace(/ /g, 'blankart')
27+
.replace(/{/g, 'alpha')
28+
.replace(/}/g, 'mega')
29+
.replace(/`/g, 'omega');
3630
};
31+
3732
export const decrypt = (str: string, salt: string) => {
3833
let encryption = encrypta(
3934
str

0 commit comments

Comments
 (0)