mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-02-04 13:29:05 +01:00
14 lines
402 B
TypeScript
14 lines
402 B
TypeScript
import crypto from 'crypto';
|
|
|
|
const randomCharacters =
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
|
export function generateRandomString(length: number): string {
|
|
let out = '';
|
|
for (let i = 0; i < length; i++) {
|
|
// Yes this is done synchronously, but it's not a big deal
|
|
out += randomCharacters[crypto.randomInt(0, randomCharacters.length - 1)];
|
|
}
|
|
return out;
|
|
}
|