Crypto-Random Problem Generation, Entirely In-Browser
AnyTool’s Math Worksheet Generator builds arithmetic practice sheets entirely client-side from a single options object: operation, digits per operand, problem count, layout and constraints. Every operand is drawn with the Web Crypto API (crypto.getRandomValues) via rejection sampling — the same unbiased randomness behind AnyTool’s password generator — so Math.random is never used and each number is uniformly distributed across its range. The same problem set feeds both the on-screen preview and a print-ready PDF assembled in the browser with pdf-lib, where page 1 is the student worksheet and an optional page 2 is the matching answer key.
- Four operations plus a mixed mode that randomises the operation per problem
- Operands drawn with crypto.getRandomValues (rejection-sampled, no modulo bias), not Math.random
- 1–4 digits per operand independently (1–9 up to 1000–9999) and 1–100 problems
- Same generated set drives the live preview and the pdf-lib PDF
- Answer key rendered on a separate page; works offline, no server, no CDN
