Random Alphanumeric Generator
Generate cryptographically secure random alphanumeric strings with custom length, character sets, and batch output. CSPRNG-powered.
About
Predictable identifiers cause collisions in databases, compromise session tokens, and weaken authentication layers. This generator uses the Web Crypto API (crypto.getRandomValues) to produce strings from a cryptographically secure pseudorandom number generator (CSPRNG), not Math.random. The output pool is constructed from user-selected character classes and filtered through rejection sampling to eliminate modulo bias. Entropy is computed as H = L × log2(N), where L is string length and N is the effective pool size after exclusions. A pool of 62 characters (A - Z, a - z, 0-9) at length 16 yields approximately 95.3 bits of entropy. The tool approximates collision probability under the birthday paradox model. Note: entropy calculations assume uniform distribution, which holds only when the CSPRNG and rejection sampling are correctly applied.
Formulas
The entropy of a randomly generated string measures the number of possible combinations expressed in bits. Higher entropy means exponentially more brute-force attempts are required.
Where H = total entropy in bits, L = length of the generated string, N = number of unique characters in the pool after exclusions.
Collision probability under the birthday paradox for k generated strings from a space of S = NL possible strings:
Where k = number of strings generated, S = NL = total keyspace size. For 1 000 000 strings at 95.3 bits entropy, collision probability is approximately 1.3 × 10−17.
Rejection sampling removes modulo bias. A random 32-bit unsigned integer r is accepted only when r < limit, where limit = 232 − (232 mod N). This ensures each character index from 0 to N − 1 has equal probability.
Reference Data
| Character Set | Pool Size (N) | Characters | Entropy per Char (bits) | Length for 128-bit Entropy |
|---|---|---|---|---|
| Digits only (0-9) | 10 | 0123456789 | 3.32 | 39 |
| Lowercase only (a - z) | 26 | abcdefghijklmnopqrstuvwxyz | 4.70 | 28 |
| Uppercase only (A - Z) | 26 | ABCDEFGHIJKLMNOPQRSTUVWXYZ | 4.70 | 28 |
| Upper + Lower | 52 | A - Z, a - z | 5.70 | 23 |
| Alphanumeric (default) | 62 | A - Z, a - z, 0-9 | 5.95 | 22 |
| Alphanumeric + Symbols | 95 | All printable ASCII | 6.57 | 20 |
| Hex (uppercase) | 16 | 0-9, A - F | 4.00 | 32 |
| Hex (lowercase) | 16 | 0-9, a - f | 4.00 | 32 |
| Base64 charset | 64 | A - Z, a - z, 0-9, +, / | 6.00 | 22 |
| Binary (0-1) | 2 | 01 | 1.00 | 128 |
| Octal (0-7) | 8 | 01234567 | 3.00 | 43 |
| Ambiguity-safe set | 57 | Alphanumeric minus 0, O, l, I, 1 | 5.83 | 22 |
| URL-safe | 64 | A - Z, a - z, 0-9, -, _ | 6.00 | 22 |
| Consonants only | 42 | BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz | 5.39 | 24 |
| Vowels + digits | 20 | AEIOUaeiou0123456789 | 4.32 | 30 |