| 1 | import { customAlphabet } from 'nanoid' |
| 2 | |
| 3 | /** |
| 4 | * Generate a secure password using nanoid |
| 5 | * Uses a custom alphabet excluding ambiguous characters (0, O, I, l) |
| 6 | * Default length is 12 characters |
| 7 | */ |
| 8 | export function generateSecurePassword(length = 12): string { |
| 9 | // Custom alphabet excluding ambiguous characters for better readability |
| 10 | const alphabet = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789' |
| 11 | const nanoidCustom = customAlphabet(alphabet, length) |
| 12 | return nanoidCustom() |
| 13 | } |
| 14 |