mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-22 19:43:16 +00:00
More maybe un-blowing-up
This commit is contained in:
1 parent
aa0e048688
commit
cad820d334
2 files changed
+14
-5
No files matched your search
@@ -24,8 +24,7 @@ import crypto from "crypto";
|
||||
|
||||
export function randomString(length = 6) {
|
||||
// Declare all characters
|
||||
const chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
// Pick characers randomly
|
||||
let str = "";
|
||||
@@ -38,8 +37,7 @@ export function randomString(length = 6) {
|
||||
|
||||
export function snowflakeBasedInvite() {
|
||||
// Declare all characters
|
||||
const chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const base = BigInt(chars.length);
|
||||
let snowflake = Snowflake.generateWorkerProcess();
|
||||
|
||||
@@ -53,3 +51,14 @@ export function snowflakeBasedInvite() {
|
||||
|
||||
return str.substr(3, 8).split("").reverse().join("");
|
||||
}
|
||||
|
||||
export function randomUpperString(length: number = 10) {
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
let result = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user