User Rating 0.0
Total Usage 0 times
Character Sets
Settings
Presets
Pool: 0 chars  |  Entropy: 0 bits  |  Strength:
Is this tool helpful?

Your feedback helps us improve.

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.

random string generator alphanumeric generator random password CSPRNG random characters secure random string generator

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.

H = L × log2(N)

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:

P(collision) 1 ek22S

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 SetPool Size (N)CharactersEntropy per Char (bits)Length for 128-bit Entropy
Digits only (0-9)1001234567893.3239
Lowercase only (a - z)26abcdefghijklmnopqrstuvwxyz4.7028
Uppercase only (A - Z)26ABCDEFGHIJKLMNOPQRSTUVWXYZ4.7028
Upper + Lower52A - Z, a - z5.7023
Alphanumeric (default)62A - Z, a - z, 0-95.9522
Alphanumeric + Symbols95All printable ASCII6.5720
Hex (uppercase)160-9, A - F4.0032
Hex (lowercase)160-9, a - f4.0032
Base64 charset64A - Z, a - z, 0-9, +, /6.0022
Binary (0-1)2011.00128
Octal (0-7)8012345673.0043
Ambiguity-safe set57Alphanumeric minus 0, O, l, I, 15.8322
URL-safe64A - Z, a - z, 0-9, -, _6.0022
Consonants only42BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz5.3924
Vowels + digits20AEIOUaeiou01234567894.3230

Frequently Asked Questions

Math.random uses a PRNG (typically xorshift128+) that is not cryptographically secure. Its internal state can be reconstructed from observed outputs, making generated tokens predictable. crypto.getRandomValues draws from the operating system's entropy pool (e.g., /dev/urandom on Linux, CryptGenRandom on Windows), producing output suitable for session tokens, API keys, and nonces. For any security-sensitive identifier, CSPRNG is mandatory.
When mapping a random 32-bit integer to a smaller range via r mod N, if 232 is not evenly divisible by N, lower indices get slightly higher probability. Rejection sampling discards values of r above the largest multiple of N that fits in 32 bits. The rejection rate is at most 1/232 per character for typical pool sizes, so performance impact is negligible.
Session tokens and CSRF tokens: minimum 128 bits (OWASP recommendation). Database primary keys (UUIDs): 122 bits (UUIDv4 standard). Short verification codes (SMS OTP): 20 - 30 bits with rate limiting. API keys for non-critical services: 80 - 128 bits. File naming to avoid collisions: 64 - 80 bits is typically sufficient.
When strings are read aloud, printed, or handwritten, characters like uppercase O and digit 0, or lowercase L and digit 1, are visually indistinguishable in many fonts. Excluding these 5 characters reduces the pool from 62 to 57, losing only 0.12 bits per character but eliminating transcription errors. Standards like Crockford's Base32 apply this principle.
No. Exclusions are applied at pool construction time, before any random sampling occurs. The effective pool is built as a single array of allowed characters. The CSPRNG then selects uniformly from this reduced pool. Entropy is recalculated against the actual pool size N after exclusions, so the displayed entropy metric remains accurate.
The generator supports lengths up to 1024 characters and batch sizes up to 500 strings. At maximum settings (1024 × 500 = 512 000 characters), generation completes in under 50 ms on modern hardware. The bottleneck is DOM rendering, not randomness generation. For larger batches, consider downloading as a text file.