How to Generate Secure Passwords: Best Practices + Free Tool
Most passwords are cracked before attackers even try them against a live system. Understanding exactly how passwords fail — and what makes one genuinely strong — changes how you think about authentication entirely.
Why You Are Searching for This
You are either setting up a new account and want to do it right, recovering from a breach, or building a system that stores passwords. In all three cases, the core problem is the same: most advice on passwords is vague ("use a mix of characters!") and misses the actual threat model. Let us start there.
Attackers do not sit at a login form and try passwords one by one. They steal hashed password databases and crack them offline at billions of attempts per second using consumer GPUs. By the time you notice a breach, your password may already be cracked. The defense is not complexity rules — it is entropy.
How Passwords Get Cracked: The Three Attack Methods
1. Brute Force
A brute force attack tries every possible combination systematically: a, b, ..., z, aa, ab, and so on. Against a 6-character lowercase password, a modern GPU cluster running Hashcat can exhaust all 308 million combinations in under a second. The only defense against brute force is length — each additional character multiplies the search space exponentially.
For an MD5-hashed password (still common in older systems), a single RTX 4090 GPU achieves roughly 60 billion hashes per second. Against bcrypt with cost factor 10, the same GPU manages only about 80,000 per second. This is why the hashing algorithm matters as much as the password itself — but you cannot control how a third-party site stores your password, so your password must be strong enough to resist cracking even if stored as MD5.
2. Dictionary Attacks
Dictionary attacks use wordlists rather than exhaustive character combinations. The RockYou2024 wordlist — compiled from real breaches — contains nearly 10 billion unique passwords. If your password is a real word, a name, a place, or any common substitution pattern (p@ssw0rd, s3cur3), it is in that list. Dictionary attacks succeed against passwords that look complex to humans but follow predictable patterns.
Common patterns that dictionary attacks cover:
- Single dictionary word:
sunshine,dragon,football - Word + number suffix:
password123,letmein2024 - Leet speak substitutions:
p@$$w0rd,h4ck3r - Keyboard walks:
qwerty,123456,qwertyuiop - Name + birth year:
john1985,sarah2001 - Capitalized word + special char:
Password!,Welcome1
3. Rainbow Tables
Rainbow tables are precomputed lookup tables that map hash values back to plaintext passwords. Instead of computing hashes during an attack, an attacker simply looks up the hash in the table. A rainbow table for MD5 hashes of all alphanumeric passwords up to 8 characters can be stored in a few terabytes and queried in milliseconds. Salting defeats rainbow tables entirely — a random salt appended to the password before hashing means no precomputed table can cover it. Any modern password storage system (bcrypt, Argon2, scrypt) adds a salt automatically. But again: you cannot control the target site.
What Actually Makes a Password Strong: Entropy
Password entropy measures unpredictability in bits. The formula is:
Entropy (bits) = log2(pool_size ^ length)
= length × log2(pool_size)
Where pool_size is the number of possible characters at each position. Examples:
- Lowercase only (26 chars), 8 chars:
8 × log2(26) = 37.6 bits - Mixed case + digits (62 chars), 8 chars:
8 × log2(62) = 47.6 bits - Full printable ASCII (95 chars), 12 chars:
12 × log2(95) = 78.9 bits - Full printable ASCII (95 chars), 16 chars:
16 × log2(95) = 105.2 bits - 4 random words from 7776-word list (diceware):
4 × log2(7776) = 51.7 bits - 6 random words from 7776-word list (diceware):
6 × log2(7776) = 77.5 bits
A password with 80+ bits of entropy is considered computationally infeasible to crack with current technology, even against a dedicated attacker with a GPU cluster. NIST recommends a minimum of 64 bits for general use.
The critical insight: length matters more than character set complexity. A 16-character lowercase password has more entropy than an 8-character password with mixed case, digits, and symbols. Complexity rules that force short passwords with symbols are worse than longer, simpler passwords.
NIST Password Guidelines 2024
NIST Special Publication 800-63B was significantly updated, and the guidance runs counter to what most people were told for years. The key recommendations:
- Minimum length of 8 characters for user-chosen passwords (15 recommended), up to 64+ characters maximum
- No mandatory complexity rules — do not require uppercase, symbols, or numbers. These rules lead to predictable patterns (
Password1!) that reduce security - No mandatory periodic rotation — forcing users to change passwords every 90 days leads to incremental patterns (
Password1!→Password2!) and reduces security - Check against breached password lists — reject passwords that appear in known breach databases
- No password hints or security questions — these are recoverable through social engineering
- Allow all printable ASCII and Unicode — do not restrict special characters
- Allow copy-paste — blocking it discourages password manager use
Real Examples: Weak vs. Strong
Here are side-by-side comparisons with estimated crack times against a 100 billion hashes/second (MD5) attack:
sunshine— 8 chars, lowercase word — instant (in every dictionary)P@ssw0rd!— 9 chars, leet speak — instant (in every dictionary)John1985!— 9 chars, name + year — instant (targeted + dictionary)Tr0ub4dor&3— 11 chars, xkcd "complex" — days to weeks (pattern-predictable)kX9#mL2$vQ7@— 12 random chars, full ASCII — thousands of years (78.9 bits)correct-horse-battery-staple— 4 random words, diceware — millions of years (51.7 bits, not in any dict)xK7!mP2@nQ9#vL4$— 16 random chars, full ASCII — heat death of universe (105 bits)
The Passphrase Method: Correct Horse Battery Staple
The webcomic XKCD popularized the passphrase concept: pick four or more random, unrelated words and combine them. The method has real mathematical backing. A passphrase like correct horse battery staple has higher entropy than Tr0ub4dor&3 and is far easier to remember and type.
The key word is random. Phrases you make up yourself are not random — they follow your thought patterns and are vulnerable to targeted attacks. True passphrases use dice (the EFF Diceware list) or a cryptographic random number generator to select words from a large wordlist:
# Python: generate a diceware-style passphrase
import secrets
# EFF large wordlist has 7776 words (6^5, for 5 dice rolls)
# Using a smaller sample here for illustration
wordlist = [
"correct", "horse", "battery", "staple", "purple",
"carpet", "river", "thunder", "bracket", "lantern",
"oxygen", "market", "frozen", "dragon", "copper",
# ... full wordlist has 7776 entries
]
passphrase = " ".join(secrets.choice(wordlist) for _ in range(6))
print(passphrase)
# e.g.: "thunder bracket lantern frozen market dragon"
Six words from a 7776-word list gives 77.5 bits of entropy — more than a 13-character random string from the full printable ASCII set, and much easier to type on mobile.
Generating Secure Passwords in Code
JavaScript (Browser & Node.js)
// CORRECT: use crypto.getRandomValues (cryptographically secure)
function generatePassword(length = 16) {
const charset =
"abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789" +
"!@#$%^&*()_+-=[]{}|;:,.<>?";
const array = new Uint32Array(length);
crypto.getRandomValues(array);
return Array.from(array, v => charset[v % charset.length]).join('');
}
// WRONG: Math.random() is NOT cryptographically secure
// Never use: charset[Math.floor(Math.random() * charset.length)]
Python
import secrets
import string
def generate_password(length=16):
# secrets module uses os.urandom — cryptographically secure
charset = (
string.ascii_lowercase +
string.ascii_uppercase +
string.digits +
"!@#$%^&*()_+-=[]{}|;:,.<>?"
)
return ''.join(secrets.choice(charset) for _ in range(length))
# Ensure all character classes are represented
def generate_strong_password(length=16):
password = [
secrets.choice(string.ascii_lowercase),
secrets.choice(string.ascii_uppercase),
secrets.choice(string.digits),
secrets.choice("!@#$%^&*"),
]
charset = string.ascii_letters + string.digits + "!@#$%^&*"
password += [secrets.choice(charset) for _ in range(length - 4)]
secrets.SystemRandom().shuffle(password)
return ''.join(password)
print(generate_strong_password(20))
# e.g.: "kX9#mL2$vQ7@nP4!rT6&"
The critical rule: always use a cryptographically secure random number generator. In Python, that is the secrets module (not random). In JavaScript, that is crypto.getRandomValues() (not Math.random()). In any language, use the OS-provided CSPRNG.
Generate a Secure Password Instantly
Set your length, pick your character set, and get a cryptographically secure random password in one click. Runs entirely in your browser — nothing is sent to any server.
Open Password GeneratorCommon Mistakes That Defeat Strong Passwords
Password Reuse
This is the single biggest risk. When a site is breached and your password is cracked, attackers run it against every other major service automatically. This is called credential stuffing. In 2024, a credential stuffing attack against Snowflake exposed data at hundreds of companies — all because employees reused passwords. Every account must have a unique password. This is only feasible with a password manager.
Patterns and Predictable Modifications
Password policies that require periodic changes lead users to make predictable modifications: Password1! → Password2! → Password3!. Cracking tools are aware of these patterns and try them first. If your base password appears in a wordlist, adding a number or year to the end provides minimal protection.
Personal Information
Names (yours, your partner's, your pet's), birth years, phone numbers, and addresses are all tried early in targeted attacks. An attacker who knows your name and approximate age can reduce the search space dramatically. Information from your social media profiles is commonly used to build custom wordlists for targeted attacks.
Using Math.random() or rand() in Code
These functions are not cryptographically secure. They use pseudo-random number generators seeded with predictable values (often the current timestamp). An attacker who knows the approximate time your password was generated can reconstruct the seed and enumerate all possible passwords your PRNG could have produced. Always use the platform's CSPRNG: secrets in Python, crypto.getRandomValues() in JS, /dev/urandom in shell.
Checking If Your Password Was Breached
Have I Been Pwned (HIBP) maintains a database of over 10 billion passwords from known breaches. You can check if a specific password has appeared in a breach without revealing the password itself, using a technique called k-anonymity:
# The HIBP API uses k-anonymity: you send only the first 5 chars of the SHA-1 hash
import hashlib
import requests
def check_pwned(password):
sha1 = hashlib.sha1(password.encode()).hexdigest().upper()
prefix, suffix = sha1[:5], sha1[5:]
response = requests.get(f"https://api.pwnedpasswords.com/range/{prefix}")
for line in response.text.splitlines():
hash_suffix, count = line.split(":")
if hash_suffix == suffix:
return int(count) # number of times seen in breaches
return 0 # not found
count = check_pwned("Password1!")
if count > 0:
print(f"This password appeared {count:,} times in known breaches. Do not use it.")
else:
print("Not found in known breaches.")
The HIBP API never receives your actual password — only the first 5 hex characters of its SHA-1 hash. This is safe to call even for passwords you are actively using.
Password Manager Recommendations
The only practical way to use a unique, randomly generated password for every site is a password manager. You memorize one strong master password; the manager stores and autofills the rest. The major options:
- Bitwarden — open source, free tier is excellent, self-hostable, audited
- 1Password — polished UX, travel mode, team features, no free tier
- KeePassXC — fully local, no cloud sync, open source, most privacy-focused
- Dashlane — includes a VPN, dark web monitoring, expensive
- iCloud Keychain / Google Password Manager — convenient if you stay within the ecosystem, but limited cross-platform support
For most users, Bitwarden is the best balance of security, usability, and cost. For high-security users who do not want cloud storage, KeePassXC with a database stored on a local encrypted drive is the gold standard.
Step-by-Step: Generating a Secure Password Right Now
- Decide on length: 16 characters minimum for standard accounts, 20+ for email and password manager master password
- Use all character classes: lowercase, uppercase, digits, and symbols
- Use a CSPRNG: Use SecureBin's password generator, your password manager's built-in generator, or the code examples above — not your own brain
- Store it in a password manager: Never write it on paper, in a text file, or in a spreadsheet
- Enable 2FA on the account: A strong password plus TOTP 2FA means an attacker who cracks your password still cannot log in
- Check HIBP: After generating, optionally verify the password has not appeared in any known breach
- Never reuse it: This password is for one account only
Frequently Asked Questions
How long should a password be in 2026?
At minimum 16 characters for a randomly generated password. For your email account and password manager master password, use 20+ characters or a 6-word diceware passphrase (77+ bits of entropy). NIST 800-63B recommends a minimum of 8 characters but notes that longer passwords are significantly more resistant to attacks. The marginal cost of adding 4 characters to a password is zero — always go longer.
Is a passphrase more secure than a random password?
It depends on the word count and wordlist size. A 4-word diceware passphrase has ~51 bits of entropy — roughly equivalent to a 9-character random password from the full ASCII set. A 6-word passphrase has ~77 bits, comparable to a 12-character random password. The advantage of passphrases is memorability and ease of typing, not raw security. For accounts stored in a password manager, a fully random 20-character string is marginally stronger. For passwords you must memorize (master password, device login), a 6-word passphrase is an excellent choice.
Should I change my password regularly if it has not been breached?
No, per NIST 800-63B. Forced periodic rotation causes users to make predictable incremental changes, which reduces security. You should change a password if: (1) the site notifies you of a breach, (2) you find the password in HIBP, (3) you suspect unauthorized access, or (4) you shared it with someone who no longer needs access. Otherwise, a strong, unique password can be kept indefinitely.
Does adding a symbol to a password make it secure?
It depends on where and how. A symbol appended to a dictionary word (password!) provides almost no protection — it is in every wordlist. A symbol that is part of a truly random character sequence (kX9#mL2$) does improve security by increasing the character pool from 62 to 95, adding about 0.6 bits of entropy per character. The real gain from symbols comes from randomness, not from the symbol itself. A 20-character lowercase random password is stronger than an 8-character password with all character classes.
Is it safe to use an online password generator?
Yes, if it runs client-side in your browser. A reputable generator uses crypto.getRandomValues() (the browser's CSPRNG) and never sends the password to any server. You can verify this by disconnecting from the internet and checking if the tool still works. SecureBin's password generator runs entirely in your browser with no network calls. Avoid generators that require you to submit a form or that make network requests when generating passwords.
What is the difference between password strength and password security?
Password strength refers to the password's resistance to cracking attacks — its entropy, character diversity, and absence from wordlists. Password security is broader: it includes how the password is stored (are you reusing it?), transmitted (HTTPS?), and protected (2FA enabled?). A perfectly strong password stored in a plain text file on your desktop is not secure. You need both strong passwords AND secure practices around them.
Do special characters like emojis make passwords stronger?
Yes, if the site allows them. Emojis extend the character pool significantly — there are over 3,600 commonly used emojis, compared to 32 printable symbols in standard ASCII. A password like kX9#mL2$🔒💻 is substantially harder to crack than one using only standard characters. However, not all sites accept Unicode in passwords, some strip or mangle non-ASCII characters, and emoji passwords are difficult to type on most keyboards. Stick to standard printable ASCII for portability; use a longer password to compensate.
Use our free tool here → SecureBin Password Generator