Skip to content

generateRandom

generateRandom(length?): string

Defined in: packages/core/src/crypto.ts:51

Generates a cryptographically random string from the RFC 7636 unreserved character set.

Uses rejection sampling to avoid modulo bias when mapping random bytes to the 66-character alphabet.

number = 32

Desired string length (default 32). RFC 7636 Section 4.1 requires at least 43 characters for code verifiers.

string

A random string of the specified length.