mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
11 lines
346 B
TypeScript
11 lines
346 B
TypeScript
export const randomString = (length: number) => {
|
|
const charSet =
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
let string = '';
|
|
for (let i = 0; i < length; i += 1) {
|
|
const randomPoz = Math.floor(Math.random() * charSet.length);
|
|
string += charSet.substring(randomPoz, randomPoz + 1);
|
|
}
|
|
return string;
|
|
};
|