8 lines
277 B
TypeScript
8 lines
277 B
TypeScript
const characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$';
|
|
|
|
export function generatePassword(length = 10) {
|
|
return Array.from(crypto.getRandomValues(new Uint32Array(length)))
|
|
.map((x) => characters[x % characters.length])
|
|
.join('');
|
|
}
|