Number of characters to generate. Returns '' for a
non-positive or non-integer length.
Optionalcharset?: string'alpha' (letters only), 'numeric' (digits
only), 'alphanumeric' (the default), or any other string, which is
used literally as the pool of characters to draw from (e.g. 'ABC123').
A random string of the requested length, or '' if length
or the resolved charset is empty.
Generates a random string of a given length, drawn from a cryptographically secure source (
globalThis.crypto.getRandomValues, the standard Web Crypto API available in both Node and browsers -- nothing here falls back toMath.random). Suitable for one-off IDs, tokens, or test fixtures.