mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 10:25:23 +00:00
Add generateRandomString helper function and remove nanoid dependency
This commit is contained in:
10
libs/common/src/helper/randomString.ts
Normal file
10
libs/common/src/helper/randomString.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export function generateRandomString(length: number): string {
|
||||
const characters =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let randomString = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||
randomString += characters.charAt(randomIndex);
|
||||
}
|
||||
return randomString;
|
||||
}
|
Reference in New Issue
Block a user