The desired length of the generated alphanumeric string
A string containing digits and lowercase letters of the specified length
RandomGenerator.alphaNumeric(8); // e.g. "a1b2c3d4"
RandomGenerator.alphaNumeric(12); // e.g. "x9y8z7w6v5u4"
// Generate random API keys
const apiKey = RandomGenerator.alphaNumeric(32);
// Create session tokens
const sessionId = `sess_${RandomGenerator.alphaNumeric(16)}`;
// Generate test database IDs
const testId = RandomGenerator.alphaNumeric(10);
contracts/common.md#principled-implementation Each character maps a Math.random draw to one of ten digits and 26 lowercase letters. Repeated characters are allowed and exact uniformity is not guaranteed.
Generates a random alphanumeric string containing digits and lowercase letters.
Creates a string of specified length using characters from 0-9 and a-z. Each position is independently randomly selected from the combined character set. Ideal for generating random IDs, tokens, passwords, or unique identifiers that need both numeric and alphabetic characters.
Processing cost: Constructing L characters costs O(L) time and intermediate/result space.