Overview
PasswordGen is a static website. When you open a page, your browser downloads HTML, CSS and JavaScript files, and that is the only communication with the server. Every password, PIN, passphrase and random string is generated by JavaScript running on your device, and the strength checker analyzes passwords in the same way. There is no backend application, no database and no API that receives your data.
1. Cryptographically secure randomness
All randomness comes from the Web Crypto API, specifically crypto.getRandomValues(). Browsers implement it with a cryptographically secure pseudo-random number generator (CSPRNG) seeded from the operating system’s entropy source. Its output is unpredictable even to someone who has seen previous values, which is exactly the property needed for passwords and keys.
PasswordGen never uses Math.random(). That function is fine for games and animations, but it is not designed to resist prediction and must not be used for secrets. An automated test in the repository fails if Math.random ever appears in the generator code.
2. Unbiased selection with rejection sampling
The random generator produces 32-bit integers (0 to 4,294,967,295). A naïve way to pick one of n characters is value % n, but unless 232 divides evenly by n, some characters come up slightly more often than others. This is called modulo bias.
PasswordGen removes it with rejection sampling: it computes the largest multiple of n that fits in the 32-bit range, discards any random value at or above that limit, and draws again. Every remaining value maps to a character equally often, so every character is exactly equally likely.
function randomInt(n) {
const limit = 2 ** 32 - (2 ** 32 % n); // largest multiple of n
let x;
do {
x = crypto.getRandomValues(new Uint32Array(1))[0];
} while (x >= limit); // reject the biased tail
return x % n;
}
Rejections are rare. With a 94-character pool only about one draw in 100 million is discarded, so this costs essentially nothing. The same unbiased function is used to shuffle, to pick passphrase words and to choose digits for PINs.
3. Measuring strength: entropy
Entropy, measured in bits, describes how many equally likely possibilities an attacker would have to search. A value with H bits of entropy is one of 2H possibilities; each extra bit doubles the work. For a value made of L characters each chosen uniformly from a pool of N characters:
entropy = L × log2(N)
| Example | Pool | Entropy |
|---|---|---|
| 6-digit PIN | 10 | ≈ 19.9 bits |
| 10 lowercase letters | 26 | ≈ 47 bits |
| 12 characters, all types | 94 | ≈ 78.7 bits |
| 6 words from 7,772 | 7,772 words | ≈ 77.5 bits |
| 32 hex characters | 16 | 128 bits |
| 20 characters, all types | 94 | ≈ 131 bits |
When you require at least one character of each selected type, a few combinations become impossible. PasswordGen accounts for this precisely using the inclusion–exclusion principle, so the number shown is the true entropy of your settings rather than an approximation.
Strength scale
PasswordGen labels entropy as Very Weak (under 28 bits), Weak (28–35), Fair (36–59), Strong (60–79) and Very Strong (80+). These thresholds are a practical guide: anything at 80 bits or more is far beyond the reach of brute-force attacks with current technology.
4. How each tool works
Password generator
Builds a pool from the character types you select, removes excluded characters, and picks each character independently. If a candidate is missing a selected type it is discarded and regenerated, which keeps the result uniform among all valid passwords.
PIN generator
Picks each digit uniformly from 0–9. With “avoid obvious patterns” on, PINs made of repeated digits, straight sequences or repeating blocks are rejected and redrawn.
Passphrase generator
Picks words uniformly from the 7,772-word EFF Large Wordlist bundled with the page, which gives about 12.9 bits per word. An optional digit is appended to a randomly chosen word.
Random string generator
Picks characters uniformly from alphanumeric, hexadecimal, custom type or fully custom sets. Custom sets are de-duplicated and split into full Unicode characters so each symbol has equal probability.
Password strength checker
Computes brute-force entropy from length and character variety, then searches for patterns: common passwords, dictionary words and leetspeak, keyboard walks, sequences, repeats, years and dates. It finds the lowest-cost combination of patterns and random characters that reproduces the password (a minimum-entropy search similar in spirit to the open-source zxcvbn approach) and reports the lower estimate.
5. Privacy architecture
- No backend. The site is served as static files from Cloudflare’s network. There is no server code that could receive a password.
- No storage of secrets. Generated and typed passwords live only in page memory. Only your theme choice (
darkorlight) is saved inlocalStorage. - No third-party scripts. No analytics, ads, tag managers, CDNs or external fonts. Everything is served from the same origin.
- Strict Content Security Policy. The site sends a CSP header that only allows scripts from its own origin and blocks connections to other servers.
- Open source. The full source code is available on GitHub for anyone to inspect.
Read the full privacy policy for details about the limited technical data our hosting provider processes.