Generates a cryptographically secure random password.
Guarantees at least 2 characters of each type (lowercase, uppercase,
digit, special) and fills the rest with Fisher-Yates shuffled
characters from the full charset. Every random index — per-class
selection, fill, and shuffle — comes from the rejection-sampled
randomIntBelow helper: no modulo bias anywhere (BL-43), no reuse
of selection bytes.
Parameters
length: number = 16
Password length (default 16). Minimum 8.
Returns string
A random password string.
Example
constpw = generateSecurePassword(20); // e.g. "kR#9mP!xL2qW@7nY&4jT"
Generates a cryptographically secure random password.
Guarantees at least 2 characters of each type (lowercase, uppercase, digit, special) and fills the rest with Fisher-Yates shuffled characters from the full charset. Every random index — per-class selection, fill, and shuffle — comes from the rejection-sampled
randomIntBelowhelper: no modulo bias anywhere (BL-43), no reuse of selection bytes.