TypeScript API / laikacms/crypto / generateSecureRandomString
Function: generateSecureRandomString()
ts
function generateSecureRandomString(length, alphabet?): string;Generate cryptographically secure random strings using rejection sampling. This eliminates modulo bias which could theoretically be exploited by quantum computers with sufficient qubits.
Uses base62 alphabet (A-Za-z0-9) for URL-safe tokens by default.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
length | number | undefined | Desired length of the output string |
alphabet | string | RANDOM_CONSTANTS.BASE62_ALPHABET | Character set to use (default: base62) |
Returns
string
Cryptographically secure random string