@8ms/helpers 2.4.5 → 2.4.7
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,21 +1,3 @@
|
|
|
1
|
-
//#region src/crypto/server/getDecrypt.d.ts
|
|
2
|
-
/**
|
|
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
|
-
*/
|
|
8
|
-
declare const getDecrypt: (salt32: string, salt16: string, input: string) => string;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/crypto/server/getEncrypt.d.ts
|
|
11
|
-
/**
|
|
12
|
-
* 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
|
-
*/
|
|
17
|
-
declare const getEncrypt: (salt32: string, salt16: string, input: string) => string;
|
|
18
|
-
//#endregion
|
|
19
1
|
//#region src/crypto/server/getMd5.d.ts
|
|
20
2
|
/**
|
|
21
3
|
* Encrypt a string using md5.
|
|
@@ -34,4 +16,4 @@ declare const getRandom: (length: number) => string;
|
|
|
34
16
|
*/
|
|
35
17
|
declare const getSha256: (input: any) => string;
|
|
36
18
|
//#endregion
|
|
37
|
-
export {
|
|
19
|
+
export { getMd5, getRandom, getSha256 };
|
|
@@ -1,34 +1,5 @@
|
|
|
1
1
|
import { t as __require } from "../../chunk-y_GBKt04.mjs";
|
|
2
2
|
import { getString } from "../../string/index.mjs";
|
|
3
|
-
import * as crypto from "crypto";
|
|
4
|
-
//#region src/crypto/server/getDecrypt.ts
|
|
5
|
-
/**
|
|
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
|
-
*/
|
|
11
|
-
const getDecrypt = (salt32, salt16, input) => {
|
|
12
|
-
const decipher = crypto.createDecipheriv("aes-256-cbc", salt32, salt16);
|
|
13
|
-
let decrypted = decipher.update(input, "hex", "utf8");
|
|
14
|
-
decrypted += decipher.final("utf8");
|
|
15
|
-
return decrypted;
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/crypto/server/getEncrypt.ts
|
|
19
|
-
/**
|
|
20
|
-
* 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
|
-
*/
|
|
25
|
-
const getEncrypt = (salt32, salt16, input) => {
|
|
26
|
-
const cipher = crypto.createCipheriv("aes-256-cbc", salt32, salt16);
|
|
27
|
-
let encrypted = cipher.update(input, "utf8", "hex");
|
|
28
|
-
encrypted += cipher.final("hex");
|
|
29
|
-
return encrypted;
|
|
30
|
-
};
|
|
31
|
-
//#endregion
|
|
32
3
|
//#region src/crypto/server/getMd5.ts
|
|
33
4
|
/**
|
|
34
5
|
* Encrypt a string using md5.
|
|
@@ -57,4 +28,4 @@ const getSha256 = (input) => {
|
|
|
57
28
|
return crypto.createHash("sha256").update(inputString).digest("hex");
|
|
58
29
|
};
|
|
59
30
|
//#endregion
|
|
60
|
-
export {
|
|
31
|
+
export { getMd5, getRandom, getSha256 };
|