function getRandomChar(charset: string) {
const index = Math.floor(Math.random() * charset.length);
return charset[index] ?? "";
}
function generateRandomString(length: number, charset: string) {
let result = "";
for (let i = 0; i < length; i += 1) {
result += getRandomChar(charset);
}
return result;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter