Evo.Auth/apps/api/utils/password.ts
2023-10-31 16:30:15 +03:00

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('');
}