triangle-utils 1.4.79 → 1.4.80
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/dist/src/UtilsMisc.d.ts +1 -0
- package/dist/src/UtilsMisc.js +3 -0
- package/package.json +1 -1
- package/src/UtilsMisc.ts +4 -0
package/dist/src/UtilsMisc.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class UtilsMisc {
|
|
|
11
11
|
static wait(duration: number): Promise<unknown>;
|
|
12
12
|
static get_current_time(): string;
|
|
13
13
|
static get_current_milliseconds(): number;
|
|
14
|
+
static get_random_string(length: number, encoding?: "binary" | "hex" | "base64"): string;
|
|
14
15
|
static sha256(input: string): Promise<string>;
|
|
15
16
|
static encrypt(secret_key: string, text: string): Encryption;
|
|
16
17
|
static decrypt(secret_key: string, encryption: Encryption): string;
|
package/dist/src/UtilsMisc.js
CHANGED
|
@@ -51,6 +51,9 @@ export class UtilsMisc {
|
|
|
51
51
|
static get_current_milliseconds() {
|
|
52
52
|
return (new Date()).getTime();
|
|
53
53
|
}
|
|
54
|
+
static get_random_string(length, encoding = "hex") {
|
|
55
|
+
return Buffer.from(crypto.randomBytes(length)).toString(encoding);
|
|
56
|
+
}
|
|
54
57
|
static async sha256(input) {
|
|
55
58
|
const text_encoder = new TextEncoder();
|
|
56
59
|
const input_buffer = text_encoder.encode(input);
|
package/package.json
CHANGED
package/src/UtilsMisc.ts
CHANGED
|
@@ -66,6 +66,10 @@ export class UtilsMisc {
|
|
|
66
66
|
return (new Date()).getTime()
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
static get_random_string(length : number, encoding : "binary" | "hex" | "base64" = "hex") : string {
|
|
70
|
+
return Buffer.from(crypto.randomBytes(length)).toString(encoding)
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
static async sha256(input : string) : Promise<string> {
|
|
70
74
|
const text_encoder = new TextEncoder()
|
|
71
75
|
const input_buffer = text_encoder.encode(input);
|