@8ms/helpers 2.4.5 → 2.4.6
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.
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
//#region src/crypto/server/getDecrypt.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Decrypt an encoding string using a salt.
|
|
4
|
-
* @param salt32 must be 32 bytes
|
|
5
|
-
* @param salt16 must be 16 bytes
|
|
6
|
-
* @param input any string
|
|
7
4
|
*/
|
|
8
|
-
declare const getDecrypt: (
|
|
5
|
+
declare const getDecrypt: (appSalt: string, input: string) => string;
|
|
9
6
|
//#endregion
|
|
10
7
|
//#region src/crypto/server/getEncrypt.d.ts
|
|
11
8
|
/**
|
|
12
9
|
* Encrypt an encoding string using a salt.
|
|
13
|
-
* @param salt32 must be 32 bytes
|
|
14
|
-
* @param salt16 must be 16 bytes
|
|
15
|
-
* @param input any string
|
|
16
10
|
*/
|
|
17
|
-
declare const getEncrypt: (
|
|
11
|
+
declare const getEncrypt: (appSalt: string, input: string) => string;
|
|
18
12
|
//#endregion
|
|
19
13
|
//#region src/crypto/server/getMd5.d.ts
|
|
20
14
|
/**
|
|
@@ -4,29 +4,19 @@ import * as crypto from "crypto";
|
|
|
4
4
|
//#region src/crypto/server/getDecrypt.ts
|
|
5
5
|
/**
|
|
6
6
|
* Decrypt an encoding string using a salt.
|
|
7
|
-
* @param salt32 must be 32 bytes
|
|
8
|
-
* @param salt16 must be 16 bytes
|
|
9
|
-
* @param input any string
|
|
10
7
|
*/
|
|
11
|
-
const getDecrypt = (
|
|
12
|
-
const decipher = crypto.createDecipheriv("aes-256-
|
|
13
|
-
|
|
14
|
-
decrypted += decipher.final("utf8");
|
|
15
|
-
return decrypted;
|
|
8
|
+
const getDecrypt = (appSalt, input) => {
|
|
9
|
+
const decipher = crypto.createDecipheriv("aes-256-ecb", appSalt, null);
|
|
10
|
+
return decipher.update(input, "hex", "utf8") + decipher.final("utf8");
|
|
16
11
|
};
|
|
17
12
|
//#endregion
|
|
18
13
|
//#region src/crypto/server/getEncrypt.ts
|
|
19
14
|
/**
|
|
20
15
|
* Encrypt an encoding string using a salt.
|
|
21
|
-
* @param salt32 must be 32 bytes
|
|
22
|
-
* @param salt16 must be 16 bytes
|
|
23
|
-
* @param input any string
|
|
24
16
|
*/
|
|
25
|
-
const getEncrypt = (
|
|
26
|
-
const cipher = crypto.createCipheriv("aes-256-
|
|
27
|
-
|
|
28
|
-
encrypted += cipher.final("hex");
|
|
29
|
-
return encrypted;
|
|
17
|
+
const getEncrypt = (appSalt, input) => {
|
|
18
|
+
const cipher = crypto.createCipheriv("aes-256-ecb", appSalt, null);
|
|
19
|
+
return cipher.update(input, "utf8", "hex") + cipher.final("hex");
|
|
30
20
|
};
|
|
31
21
|
//#endregion
|
|
32
22
|
//#region src/crypto/server/getMd5.ts
|