summaryrefslogtreecommitdiff
path: root/src/misc/secure-rndstr.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/secure-rndstr.ts')
-rw-r--r--src/misc/secure-rndstr.ts21
1 files changed, 0 insertions, 21 deletions
diff --git a/src/misc/secure-rndstr.ts b/src/misc/secure-rndstr.ts
deleted file mode 100644
index 76ee1225eb..0000000000
--- a/src/misc/secure-rndstr.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import * as crypto from 'crypto';
-
-const L_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz';
-const LU_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-
-export function secureRndstr(length = 32, useLU = true): string {
- const chars = useLU ? LU_CHARS : L_CHARS;
- const chars_len = chars.length;
-
- let str = '';
-
- for (let i = 0; i < length; i++) {
- let rand = Math.floor((crypto.randomBytes(1).readUInt8(0) / 0xFF) * chars_len);
- if (rand === chars_len) {
- rand = chars_len - 1;
- }
- str += chars.charAt(rand);
- }
-
- return str;
-}