Custom String Generator
Generate random strings with custom length, character sets, patterns, separators, and prefixes. Cryptographically secure CSPRNG output.
About
Generating random strings without cryptographic guarantees produces predictable output vulnerable to brute-force attacks. This tool uses the browser's native crypto.getRandomValues API - a cryptographically secure pseudorandom number generator (CSPRNG) - to produce strings with verifiable entropy. Entropy per string is calculated as H = L × log2(N), where L is the output length and N is the character pool size. A pool of 62 alphanumeric characters at length 16 yields approximately 95.3 bits of entropy - sufficient for session tokens but insufficient for master encryption keys. This tool approximates uniform distribution by rejection sampling when the pool size does not evenly divide 256.
Pattern mode lets you define structural templates (e.g., AAA-9999) for serial numbers, coupon codes, or license keys. Note: uniqueness is enforced via deduplication, but generating more strings than the combinatorial space allows will halt with an error rather than producing duplicates. Pro tip: for API tokens, use at least 128 bits of entropy - that means 22 characters from a 62-character alphanumeric pool.
Formulas
The information entropy of a randomly generated string quantifies its resistance to brute-force enumeration. Given a character pool of size N and a string length L, the entropy in bits is:
Where H = entropy in bits, L = number of characters in the generated string, N = total unique characters in the pool. The total combinatorial search space is NL. For example, an alphanumeric pool (N = 62) at length 16 gives 6216 ≈ 4.77 × 1028 possible strings.
Rejection sampling ensures uniform distribution. A random byte (0 - 255) is generated and accepted only if it falls below the largest multiple of N that fits in 256:
Bytes ≥ threshold are discarded and resampled, eliminating modulo bias.
Reference Data
| Character Set | Pool Size (N) | Bits per Char | Length for 128-bit Entropy | Example Characters |
|---|---|---|---|---|
| Lowercase only | 26 | 4.70 | 28 | a - z |
| Uppercase only | 26 | 4.70 | 28 | A - Z |
| Digits only | 10 | 3.32 | 39 | 0-9 |
| Lowercase + Digits | 36 | 5.17 | 25 | a - z, 0-9 |
| Alphanumeric (mixed) | 62 | 5.95 | 22 | a - z, A - Z, 0-9 |
| Alphanumeric + Symbols | 94 | 6.55 | 20 | a - z, A - Z, 0-9, !@#$... |
| Hex (lowercase) | 16 | 4.00 | 32 | 0-9, a - f |
| Hex (uppercase) | 16 | 4.00 | 32 | 0-9, A - F |
| Base64 charset | 64 | 6.00 | 22 | A - Z, a - z, 0-9, +, / |
| Binary | 2 | 1.00 | 128 | 0, 1 |
| Octal | 8 | 3.00 | 43 | 0-7 |
| ASCII printable | 95 | 6.57 | 20 | Space through ~ |
| Vowels only | 10 | 3.32 | 39 | a, e, i, o, u (both cases) |
| Consonants only | 42 | 5.39 | 24 | b - z minus vowels (both cases) |
| Ambiguity-free | 57 | 5.83 | 22 | Excludes 0/O, 1/l/I, 5/S |