Developer Password Generators
Copy-paste-ready code for generating cryptographically secure passwords in the language you're already using. Each example uses that language's secure randomness source — never a general-purpose or seeded PRNG.
Why the Randomness Source Matters
Every mainstream language ships two categories of random number generator: a fast, statistically-random one meant for simulations and games (random, Math.random(), java.util.Random), and a slower, cryptographically secure one meant for security-sensitive values (secrets, crypto.getRandomValues(), SecureRandom). Using the wrong one is one of the most common real-world password-generation bugs — the output looks random but can be predicted or reproduced by an attacker who knows (or guesses) the internal PRNG state or seed.
| Language | Use this | Never use this for passwords |
|---|---|---|
| Python | secrets | random |
| JavaScript | crypto.getRandomValues() | Math.random() |
| Java | java.security.SecureRandom | java.util.Random |
| C# | RandomNumberGenerator | System.Random |
| PowerShell | RNGCryptoServiceProvider / RandomNumberGenerator | Get-Random (weaker PRNG) |
| MySQL | Generate outside the DB, or UUID() as an input | RAND() |
Common Mistakes Across Languages
- Seeding a PRNG with a fixed or predictable value — the time, a process ID, or a hardcoded constant — defeats the purpose of generating a password at all, regardless of which language you're in.
- Applying modulo directly to a random byte or integer to pick a character index. Unless the pool size evenly divides the random source's range, this skews some characters to appear more often than others. Rejection sampling (shown in each language's example below) removes the bias.
- Logging the generated password during development and forgetting to remove it — application logs, error trackers, and debug output are not secure storage.
- Not guaranteeing at least one character from each required type when sampling purely at random from a combined pool — statistically rare failures (a password with all types enabled but zero symbols) are still possible without an explicit guarantee.
All Developer Guides
Python Password Generator
Using the secrets module — the standard-library way to generate secure passwords in Python.
JavaScript Password Generator
Browser and Node.js examples using the Web Crypto API.
View code →Java Password Generator
Using java.security.SecureRandom for secure password generation.
C# Password Generator
Using System.Security.Cryptography.RandomNumberGenerator in .NET.
PowerShell Password Generator
A command-line script for generating secure passwords on Windows.
View code →MySQL Password Generator
Generating secure passwords for MySQL user accounts, and why not to use SQL's RAND().