How much security each character adds
Strength is measured in bits of entropy: the string length multiplied by log2 of the number of characters allowed. Each extra bit doubles the number of possible strings.
- Digits only (10 characters): 3.32 bits each.
- Lowercase only (26): 4.70 bits each.
- Letters and digits (62): 5.95 bits each, so 16 characters give about 95 bits and 32 give about 190.
- Letters, digits and the 26 symbols here (88): 6.46 bits each.
About 128 bits is far beyond any realistic guessing attack, which works out to 22 characters of letters and digits.
What each preset produces
- Alphanumeric: 16 letters and digits, about 95 bits.
- Strong: 24 characters with symbols and without look-alikes, drawn from 83 characters for about 153 bits.
- API: 32 uppercase letters and digits without look-alikes. That leaves exactly 32 characters, worth 5 bits each, for 160 bits.
- UUID: a standard version 4 identifier with 122 random bits. The length and character options do not apply to it.
Why the source of randomness matters
Each character comes from crypto.getRandomValues, the secure generator built into your browser. JavaScript’s Math.random is designed for speed and its output can be predicted, so it should never produce secrets.
Dividing a random number by the alphabet size can favor some characters slightly. To avoid that, values above the last whole multiple of the alphabet size are thrown away and drawn again, which keeps every character equally likely.
Choosing characters that will not cause trouble
Symbols add little and can break things. A $ can expand in a shell, & splits a URL query, and quotes can end a value in a config file. For environment files, links and database passwords, a longer string of letters and digits is usually the safer choice.
Turn on Exclude ambiguous when someone has to read or type the code, since 0, O, 1, l and I are easy to confuse on paper. Store real secrets in a secrets manager rather than in chat or email.