Notes › Tech Notes › Charset Pool and Exclusions on the Random Password Page, Measured

Charset Pool and Exclusions on the Random Password Page, Measured

All four boxes checked, the pool measures 94, matching the comment 26+26+10+32. Ambiguous-character exclusion removes 0 to 5 characters by combination; symbols-only loses none. A blank length or a 0 falls back to the default 16 instead of clamping to 4. In a 2000-row sample, only 131 rows carry all four classes.

The Digits Box Is Checked, Yet the Short String Holds Not One Digit

A while back I tried charset combinations here: digits checked, length filled as 4, five rows generated — one line came out entirely letters. First reaction: the checkbox failed. Only after loading the template's script block verbatim into Node (minimal DOM stub, no browser) and measuring every function did I find my expectation of the generation loop had been wrong — it draws each position independently from the merged pool, with no "top up one per class" logic. This post keeps two accounts: the arithmetic of the character pool, and where the controls clamp and fall back. Every number comes from calling the page's own functions.

Pool composition: the symbol string really counts 32, and the comment's 94 holds word for word

The Random Password page shows five checkboxes, and only three carry checked in the source — uppercase, lowercase, digits — so special symbols and ambiguous-character exclusion default to off. The uppercase string 26, the lowercase string 26 and the digits string 10 are plain literals; the symbols string is not hardcoded — a loop scans ASCII code points from 33 to 126, drops letters and digits, and concatenates the rest: 32 characters measured, still 32 after dedup, none of the non-alphanumerics among these 94 printable code points missing. So all four classes give a pool of 62 + 32 = 94, matching the template comment's 26+26+10+32 = 94 word for word. All 14 checking combinations were tested: no pool repeats a character, and the deduped length equals the pool length.

Net removal of the same switch floats with the combination All four classes 94 → 89 Three defaults 62 → 57 Uppercase only 26 → 24 Lowercase only 26 → 25 Digits only 10 → 8 Symbols only 32 → 32, removed 0

Figure 1 Pool length across six checking combinations, before and after the exclusion switch

Exclusion is not a fixed cut of five: the net removal ranges from 0 to 5 by combination

The exclusion is one regular-expression replacement deleting the character class [0O1lI] from the assembled pool — pure set subtraction, and how many it removes depends on how many the checked pools cover. The page label reads, word for word, "Exclude ambiguous characters (0 O 1 l I)" — indeed 5; the tool-list copy "excludes 0/O/1/l and similar" omits the capital I, which the measured regex includes. The account:

Checking combinationPool lengthAfter also checking exclusionNet removed
All four classes94895
Three defaults (upper + lower + digits)62575
Uppercase only26242 (O, I)
Lowercase only26251 (l)
Digits only1082 (0, 1)
Symbols only32320

The last row is the easiest to miss: none of these 5 characters is in the symbols pool, so with symbols only the switch is checked for nothing and the pool stays 32. To audit removal points yourself, a set difference between two character runs is more direct — that account lives on the Text Set page. This switch has no preview; it only shows in the usable output characters: check it, regenerate 5 rows, and rows containing any of the 5 count 0.

Two clamp layers on the length field: entering 0 or leaving it blank returns the default

The HTML min/max is one layer; Math.max / Math.min plus a parseInt || fallback in the JS is another; the generation chain only honors the latter. Calling the page's own read function: out-of-range 3 lands on 4, 129 and 200 land on 128, row count 150 clamps to 100. But entering 0, leaving it blank, or typing letters returns the defaults 16 and 5, not the minimum — parseInt("0") is falsy and drops into the fallback. Decimals truncate without rounding: "12.7" becomes 12, row count "2.9" becomes 2. The most counter-intuitive is "1e3": parseInt swallows only the leading 1, which is then clamped back up to 4. The row-count field is built the same — "abc" also returns 5 — and it registers no refresh listener, so editing the count leaves the info bar stale.

Length field: input to actual value (JS-layer landing point) 3 → 4 (floor clamp) 0 → 16 (falsy, default returned) blank → 16 (same path) 12.7 → 12 (truncated) 1e3 → 1 → 4 (swallows 1, then floor clamp) 129 → 128 (ceiling clamp) rows 150 → 100 rows 2.9 → 2 rows abc → 5 (default) 0000064 → 64

Figure 2 Clamp and fallback landing points of the two numeric fields, measured via the page's own read functions

No guarantee of at least one per class: the missing-class account of a 2000-row sample

The generation loop draws each position independently and uniformly from the merged pool: no top-ups, no rerolls. Two samples of 2000 rows quantify it. On the full 94 pool at length 4, only 131 rows carry all four classes — 1273 miss digits, 547 miss uppercase, 583 miss lowercase, 371 miss symbols; on short rows a missing class is the norm, not an edge case. On the default 62 pool at length 16, a fresh 2000-row sample has 131 rows missing digits, and missing uppercase and lowercase both count 0: at a share of 26/62, a long string almost surely covers every class. On the same pool at length 8, 944 rows come out complete. If a workflow depends on every class appearing, this page gives no such guarantee; audit row by row.

The batch account: 100 rows by 128 positions, two runs at 1.2895 ms and 2.278 ms

In the script block, crypto.getRandomValues appears 1 time and Math.random 0 times. Each row first grabs len random words 32 positions wide in one call, then maps every position modulo the pool length to a character. Measured on the 100-row by 128-position batch: exactly 100 crypto calls, 12800 words drawn, and the two whole-batch runs took 1.2895 ms and 2.278 ms; rows all came out 128 long, still 100 after dedup — zero repeats within a batch, but there is no duplicate-check branch, so repeats are left to pool length and luck. Generating 5 rows twice back-to-back with identical parameters yields 0 matches: the same settings never reproduce the same batch. On the default pool, 100 rows at 16 positions run 20 times in a row average 0.44 ms.

After the empty-pool error, the old results stay exactly as they were

With all four classes unchecked (exclusion still ticked), the pool length is 0. The info bar and the toast carry the same sentence, "please select at least one character type"; the toast type is error; generation returns immediately. What matters is the order: the assignment that clears the list sits after the empty check, so the error branch never reaches it. A small probe verified the residue — generate 5 rows at defaults, uncheck all three default boxes, click generate: one extra toast only, the old 5 rows stay in the list, the first entry keeps its old value, and the results area does not hide. Removing them takes the "clear" button: empties the list, hides the results area, no preconditions.

Copy conflicts checked along the way

The info bar live-displays the current character-set count as the boxes change; this page's account ends there, and the tool's remaining scope is left to another note, not expanded here. Three hard copy-vs-code conflicts: "set any length from 4~128" contradicts the fallback where 0 or a blank box returns the default 16; the exclusion line "0/O/1/l and similar" omits the capital I; and the tiered-display sentence in the list intro has no matching branch anywhere in the 80 script segments — that belongs to another page. The template comment's 32 and 94, by contrast, hold item by item under measurement.

FAQ

Q1 Digits are checked — why can a short string contain none?

Checking decides the composition of the pool, never of each row. On the pool of 94 at length 4, a sample of 2000 rows yields only 131 complete ones, and the 1273 rows missing digits are the largest gap. The shorter the row and the more classes checked, the more common a missing class.

Q2 Exclusion is checked with symbols only — why does the pool not change?

The switch deletes the 5 characters [0O1lI]. The symbols string is built from code points 33 to 126 with letters and digits stripped, so it never contained them: the net cut is 0 and the pool stays 32. Removal depends on the combination, not a fixed five.

Q3 I entered length 0 — why did I get a 16-character string?

Passed through parseInt, 0 is falsy, so the fallback returns the default 16 instead of clamping down to the minimum 4; only the out-of-range 3 lands on 4. A blank box and typed letters behave the same; the row-count field mirrors it, returning 5.

Q4 After the error, are the old rows in the list a bug?

By the code's reading the order is deliberate: clearing runs after the empty-check return, so the error path never touches it. Measured: the old 5 rows linger and the results area stays visible; only a manual "clear" removes them.

📎 Related articles

JSON to YAML Reorders Keys and Quotes Numbers: Output Side and 4 Indent Tiers 2026-11-29 270° Clamps to 180°, Not -90°: The Angle Clamp and Canvas Ledger 2026-11-29 The PNG Quality Slider Spins for Nothing at Every Byte Size 2026-11-29 Text Set Operations Measured: Duplicates and Order 2026-11-28 HTML Beautify Deletes the Blank Line Inside pre 2026-11-28