DevToolBoxGRATIS
Blogg

Password Generator Online: How to Create Strong, Secure, Random Passwords

15 min readby DevToolBox

In a world where data breaches expose billions of credentials every year, using strong, unique passwords for every account is no longer optional. Yet most people still rely on weak, reused passwords that attackers can crack in seconds. A random password generator eliminates human bias and creates cryptographically strong passwords that resist brute-force, dictionary, and rainbow table attacks. This comprehensive guide covers everything you need to know about generating secure passwords: the math behind password strength, how modern attacks work, NIST guidelines for 2024, generating passwords programmatically in JavaScript and Python, the passphrase vs. password debate, password manager integration, and two-factor authentication. Whether you are a developer securing user accounts or an individual protecting personal data, this guide will give you the knowledge to make informed decisions about password security.

TL;DR

  • Use a random password generator for every account. Never create passwords from memory.
  • Minimum 16 characters with uppercase, lowercase, digits, and symbols for maximum entropy.
  • Passphrases (4-6 random words) are equally strong and easier to type on mobile.
  • Store all passwords in a password manager. Memorize only the master password.
  • Enable two-factor authentication (TOTP or hardware key) on every account that supports it.
  • NIST 2024 says: longer is better, no forced rotation, check against breach databases.

Key Takeaways

  • A 16-character random password with mixed characters has over 105 bits of entropy, requiring trillions of years to brute-force.
  • Dictionary attacks crack human-chosen passwords in minutes. Random generation is the only reliable defense.
  • Password entropy = log2(pool_size ^ length). Every additional character multiplies the search space exponentially.
  • NIST SP 800-63B (2024 update) recommends allowing 64+ character passwords and checking against breach lists.
  • Passphrases using 6 Diceware words provide 77+ bits of entropy with better memorability.
  • Two-factor authentication reduces account compromise by over 99% even if the password is leaked.

1. Why Strong Passwords Matter More Than Ever

The scale of credential theft has reached staggering proportions. In 2024 alone, over 1.5 billion unique username-password combinations were leaked in data breaches. The RockYou2024 compilation contained nearly 10 billion entries. Attackers use these leaked credentials in automated credential-stuffing attacks, trying each stolen password across hundreds of popular services. If you reuse a password, a single breach compromises every account that shares it.

  • Credential stuffing attacks test millions of stolen passwords per hour against login forms.
  • A single reused password can cascade into email, banking, cloud storage, and social media compromise.
  • Automated tools like Hashcat can test 100 billion password hashes per second on consumer GPUs.
  • The average cost of a data breach reached $4.88 million in 2024 according to IBM.

The solution is straightforward: use a different, randomly generated password for every account. A password generator removes human predictability and creates passwords that are mathematically resistant to all known attack methods.

2. Password Entropy Explained: The Math Behind Security

Password entropy measures the unpredictability of a password in bits. It is calculated using the formula: H = L * log2(R), where L is the password length and R is the size of the character pool (the number of possible characters for each position). Higher entropy means the password is exponentially harder to guess.

Character Pool Sizes and Their Entropy Per Character

Character SetPool Size (R)Bits Per CharacterExample
Digits only (0-9)103.327291048365
Lowercase (a-z)264.70qmxbftzdkw
Upper + Lower (A-Za-z)525.70kRmBpTzYdW
Alphanumeric (A-Za-z0-9)625.95k9mB2TzY0W
Full ASCII printable956.57k9$B2!zY@W

Total Entropy for Common Password Lengths

LengthDigits OnlyLowercaseAlphanumericFull ASCII
8 chars26.6 bits37.6 bits47.6 bits52.6 bits
12 chars39.9 bits56.4 bits71.5 bits78.8 bits
16 chars53.2 bits75.2 bits95.3 bits105.1 bits
20 chars66.4 bits94.0 bits119.1 bits131.4 bits
24 chars79.7 bits112.8 bits142.9 bits157.7 bits

These calculations assume every character is chosen uniformly at random. Human-chosen passwords have far lower effective entropy because humans follow predictable patterns: dictionary words, names, dates, keyboard walks (qwerty), and common substitutions (@ for a, 3 for e). A password like "P@ssw0rd!" looks complex but has very low effective entropy because attackers already test these patterns first.

Recommended entropy targets for 2024-2025:

  • General web accounts: 60+ bits (16-char alphanumeric or 12-char full ASCII)
  • Financial and email accounts: 80+ bits (16-char full ASCII or 6-word passphrase)
  • Encryption keys and master passwords: 100+ bits (20-char full ASCII or 8-word passphrase)
# Entropy Formula
H = L * log2(R)

# Example: 16-char password, full ASCII (95 chars)
H = 16 * log2(95) = 16 * 6.57 = 105.1 bits

# Time to brute-force at 100 billion hashes/sec:
# 2^105.1 / 100,000,000,000 = ~1.29 * 10^21 seconds
# = ~40.9 trillion years

# For comparison, the universe is ~13.8 billion years old

3. What Makes a Password Strong

A strong password has three essential properties: length, randomness, and uniqueness. Complexity (mixing character types) is helpful but secondary to these three.

Length Is the Most Important Factor

Each additional character multiplies the search space by the pool size. Going from 8 to 16 characters with full ASCII increases the search space from 6.6 quadrillion to 44 octillion possibilities. NIST recommends allowing passwords up to 64 characters or more. For generated passwords, 16-20 characters is the sweet spot between security and usability.

True Randomness Eliminates Patterns

Humans are terrible at generating random sequences. We gravitate toward dictionary words, names, dates, and keyboard patterns. A cryptographically secure random number generator (CSPRNG) produces output that is computationally indistinguishable from true randomness, eliminating all predictable patterns that attackers exploit.

Uniqueness Prevents Credential Stuffing

Every account must have a different password. If you use the same password for your email and a small forum site, a breach of the forum gives attackers your email password. Since email is the recovery mechanism for most accounts, this single reuse can compromise your entire digital identity.

Character Diversity Increases Pool Size

Including uppercase, lowercase, digits, and symbols increases the per-character entropy from 4.70 bits (lowercase only) to 6.57 bits (full ASCII). At 16 characters, that difference means 75.2 bits vs 105.1 bits of entropy, roughly a trillion-fold increase in the search space.

4. Password Length vs. Complexity: Which Matters More?

This is one of the most common questions in password security. The answer is clear: length wins. A longer password with a smaller character set is almost always stronger than a shorter password with a larger character set.

Consider these two passwords:

k9$B (4 chars, full ASCII, 95 pool): entropy = 4 * 6.57 = 26.3 bits
correcthorsebatterystaple (25 lowercase chars, 26 pool): entropy = 25 * 4.70 = 117.5 bits

The 25-character lowercase password is billions of times stronger than the 4-character complex one. This is why NIST moved away from complexity requirements and toward length-based policies.

Breaking point analysis: at what length does each character set reach 80 bits of entropy (recommended minimum for important accounts)?

Character SetPool SizeChars Needed for 80 BitsChars Needed for 100 Bits
Digits (0-9)1025 chars31 chars
Lowercase (a-z)2618 chars22 chars
Alphanumeric (A-Za-z0-9)6214 chars17 chars
Full ASCII printable9513 chars16 chars

Best practice: Use full ASCII character set with 16+ characters. This achieves 105+ bits of entropy, providing an enormous security margin against all known and foreseeable attacks.

5. NIST Password Guidelines 2024: What Has Changed

The National Institute of Standards and Technology (NIST) updated its Digital Identity Guidelines (SP 800-63B) with significant changes that reflect modern understanding of password security. These guidelines are mandatory for US federal agencies and widely adopted by the private sector.

1
Minimum 8 characters, recommend 15+

NIST sets 8 characters as the absolute floor but explicitly states that longer passwords should be encouraged. Many organizations now set 12-16 as their minimum following this guidance.

2
Allow up to 64+ characters

Password fields must accept at least 64 characters. There is no security reason to limit password length. Truncating passwords is explicitly prohibited.

3
No composition rules

Requiring uppercase, lowercase, digits, and symbols is no longer recommended. These rules lead to predictable patterns without meaningfully improving security.

4
No forced periodic rotation

Passwords should only be changed when there is evidence of compromise. Forced rotation leads to weaker passwords through predictable increment patterns.

5
Check against breach databases

When users set or change passwords, the system must check them against known breached password lists. The Have I Been Pwned API provides a free, privacy-preserving way to do this.

6
Allow paste in password fields

Blocking paste in password fields actively harms security by preventing password manager usage. NIST explicitly requires that paste be allowed.

The overall theme is clear: make it easy for users to use long, unique, randomly generated passwords. Remove barriers (complexity rules, paste blocking, short max lengths) and add protections (breach checking, rate limiting, MFA).

# NIST SP 800-63B (2024) Summary
+----------------------------------+----------------------------------+
| REMOVED (DO NOT)                 | REQUIRED / RECOMMENDED           |
+----------------------------------+----------------------------------+
| Composition rules                | Min 8 chars (recommend 15+)      |
| Forced periodic rotation         | Allow 64+ characters             |
| Password hints                   | Check against breach databases   |
| Security questions (KBA)         | Allow paste in password fields   |
| Truncating passwords             | Support all Unicode characters   |
| Blocking paste                   | Rate-limit failed attempts       |
+----------------------------------+----------------------------------+

6. Common Password Attacks and How Random Passwords Defend Against Them

Understanding how attackers crack passwords helps explain why random generation is essential. There are four primary attack methods, and each exploits different weaknesses in password creation.

Brute-Force Attacks

A brute-force attack systematically tries every possible combination of characters until the correct password is found. Modern GPUs running tools like Hashcat can test billions of combinations per second against leaked password hashes. Defense: length. A 16-character random password with full ASCII has 95^16 possible combinations, which would take longer than the age of the universe to brute-force even at 100 billion attempts per second.

Dictionary Attacks

Dictionary attacks try common words, names, phrases, and known passwords from previous breaches. They also apply common transformations: capitalizing the first letter, appending numbers, replacing letters with symbols (l33t speak). This is why "Password123!" is cracked instantly despite having 12 characters and multiple character types. Defense: randomness. A truly random password contains no dictionary words or predictable patterns for dictionary attacks to exploit.

Rainbow Table Attacks

A rainbow table is a precomputed lookup table that maps hash values back to their original passwords. Instead of computing hashes at attack time, the attacker looks up the hash in the table. This trades computation time for storage space. Defense: salting (handled by the server) and length. Modern password hashing algorithms like Argon2id and bcrypt automatically apply unique salts, making rainbow tables useless. Long random passwords are also too numerous to precompute.

Credential Stuffing

Credential stuffing uses username-password pairs leaked from one service to attempt login on other services. It exploits the fact that people reuse passwords across multiple accounts. Automated tools can test millions of stolen credentials per hour. Defense: uniqueness. If every account has a different randomly generated password, a breach of one service cannot compromise any other account.

A randomly generated password of 16+ characters effectively neutralizes all four attack types. Brute-force is mathematically infeasible, dictionary attacks find no patterns, rainbow tables cannot contain it, and uniqueness prevents credential stuffing.

# Attack Speed Reference (2024 Hardware)
# ─────────────────────────────────────────────────
# Hash Type        │ Speed (hashes/sec)  │ Hardware
# ─────────────────┼─────────────────────┼─────────
# MD5              │ 150 billion         │ RTX 4090
# SHA-256          │ 22 billion          │ RTX 4090
# bcrypt (cost=12) │ 32,000              │ RTX 4090
# Argon2id         │ ~1,000              │ RTX 4090
# ─────────────────────────────────────────────────
# A 16-char full ASCII password (95^16):
# MD5:      95^16 / 150e9 = ~2.9e17 seconds = ~9.2 billion years
# Argon2id: 95^16 / 1000  = ~4.4e25 seconds = ~1.4e18 years

7. Generating Passwords Programmatically

If you need to generate passwords in your applications, it is critical to use a cryptographically secure random number generator (CSPRNG). Standard random functions (Math.random() in JavaScript, random.random() in Python) are not cryptographically secure and must never be used for password generation.

JavaScript / Node.js (using Web Crypto API)

// Password Generator using Web Crypto API (browser & Node.js 19+)
function generatePassword(length = 16, options = {}) {
  const {
    uppercase = true,
    lowercase = true,
    digits = true,
    symbols = true,
  } = options;

  let charset = '';
  if (uppercase) charset += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  if (lowercase) charset += 'abcdefghijklmnopqrstuvwxyz';
  if (digits)    charset += '0123456789';
  if (symbols)   charset += '!@#$%^&*()_+-=[]{}|;:,.<>?';

  if (charset.length === 0) {
    throw new Error('At least one character type must be enabled');
  }

  // Use crypto.getRandomValues for cryptographic security
  const array = new Uint32Array(length);
  crypto.getRandomValues(array);

  let password = '';
  for (let i = 0; i < length; i++) {
    password += charset[array[i] % charset.length];
  }

  return password;
}

// Usage
console.log(generatePassword(16));
// Example output: "k9$Bm2!zYp@W7xQf"

console.log(generatePassword(20, { symbols: false }));
// Example output: "kR9mB2pTzY0WdXf7Qa4J"

// Calculate entropy
const poolSize = 95; // full ASCII
const length = 16;
const entropy = length * Math.log2(poolSize);
console.log(`Entropy: ${entropy.toFixed(1)} bits`);
// Output: "Entropy: 105.1 bits"

Python (using secrets module)

import secrets
import string
import math

def generate_password(length=16, uppercase=True, lowercase=True,
                      digits=True, symbols=True):
    """Generate a cryptographically secure random password."""
    charset = ''
    if uppercase: charset += string.ascii_uppercase
    if lowercase: charset += string.ascii_lowercase
    if digits:    charset += string.digits
    if symbols:   charset += string.punctuation

    if not charset:
        raise ValueError('At least one character type must be enabled')

    # secrets.choice uses os.urandom (CSPRNG)
    password = ''.join(secrets.choice(charset) for _ in range(length))
    return password


def generate_passphrase(num_words=6, separator='-'):
    """Generate a Diceware-style passphrase."""
    # In production, use a proper Diceware word list
    # This is a simplified example
    import pathlib
    wordlist_path = '/usr/share/dict/words'
    words = [w.strip().lower() for w in open(wordlist_path)
             if 3 <= len(w.strip()) <= 8 and w.strip().isalpha()]
    return separator.join(secrets.choice(words) for _ in range(num_words))


def password_entropy(password, pool_size):
    """Calculate password entropy in bits."""
    return len(password) * math.log2(pool_size)


# Usage
pw = generate_password(16)
print(f"Password: {pw}")
print(f"Entropy:  {password_entropy(pw, 95):.1f} bits")

pp = generate_passphrase(6)
print(f"Passphrase: {pp}")
# Example: "marble-tornado-pencil-silk-anchor-cloud"

Warning: Critical: Always use crypto.getRandomValues() in JavaScript or the secrets module in Python for password generation. The standard Math.random() and random.random() are pseudorandom number generators that can be predicted if the internal state is known. They are not suitable for any security-sensitive purpose.

Quick password generation in the browser console

// Quick one-liner for browser console
// Generates a 20-char password with full ASCII
Array.from(crypto.getRandomValues(new Uint32Array(20)),
  v => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*"[v % 72]
).join('')

For everyday use, simply use our online password generator tool which implements all these best practices with a user-friendly interface.

8. Passphrase vs. Password: Which Is Better?

A passphrase is a password composed of multiple randomly selected words instead of random characters. The most well-known method is Diceware, which uses physical dice to select words from a list of 7,776 words. The security of a passphrase comes from the number of words and the size of the word list.

Passphrase vs Random Password Comparison

TypeExampleEntropyMemorability
16-char randomk9$Bm2!zYp@W7xQf105 bitsVery hard to memorize
4-word passphrasecorrect horse battery staple51.7 bitsEasy to memorize
6-word passphrasepencil tornado marble silk anchor cloud77.5 bitsModerate to memorize
8-word passphrasetrophy canal wagon planet lemon oxide fern quartz103.4 bitsHarder to memorize

When to use a passphrase:

  • Master passwords for password managers (you need to memorize this one)
  • Full-disk encryption passwords (typed frequently before OS loads)
  • SSH key passphrases (typed manually without autofill)
  • Any situation where you must type the password manually without a password manager

When to use random character passwords:

  • All accounts managed by a password manager (autofilled, no need to type)
  • API keys and service tokens (never typed manually)
  • When maximum entropy per character is needed (short max-length fields)

The key insight: passphrases sacrifice entropy density for memorability. A 6-word passphrase has 77.5 bits of entropy spread across roughly 35 characters, while a 12-character random password achieves 78.8 bits. Both are strong, but the passphrase is easier to remember and type.

# Entropy comparison: Passphrase vs Random Password
# ─────────────────────────────────────────────────────────────
# Type                  │ Characters │ Entropy    │ Brute-force
# ──────────────────────┼────────────┼────────────┼────────────
# 4-word Diceware       │ ~22 chars  │ 51.7 bits  │ ~71 years
# 6-word Diceware       │ ~35 chars  │ 77.5 bits  │ ~4.7e15 yrs
# 8-word Diceware       │ ~47 chars  │ 103.4 bits │ ~3.2e23 yrs
# 12-char random ASCII  │ 12 chars   │ 78.8 bits  │ ~9.5e15 yrs
# 16-char random ASCII  │ 16 chars   │ 105.1 bits │ ~1.3e24 yrs
# 20-char random ASCII  │ 20 chars   │ 131.4 bits │ ~1.1e31 yrs
# ─────────────────────────────────────────────────────────────
# (Assuming 100 billion hashes/sec with SHA-256)

9. Password Managers: The Essential Companion to Password Generators

A random password generator is only useful if you have a way to store and retrieve the passwords it creates. This is where password managers come in. A password manager is an encrypted vault that stores all your passwords, auto-fills them in login forms, and syncs across your devices.

Why you need a password manager:

  • The average person has 100+ online accounts. You cannot memorize 100 unique 16-character random passwords.
  • Password managers auto-fill credentials, which is both faster and more secure than typing passwords. Auto-fill also protects against phishing because the manager verifies the domain before filling.
  • Most password managers include a built-in password generator, making it trivial to create a unique random password for every new account.
  • Password managers encrypt your vault with your master password using algorithms like Argon2id or PBKDF2. Even if the encrypted vault is stolen, the passwords remain secure.

Tips for using a password manager securely:

1Choose a master password of 5-6 Diceware words (77+ bits of entropy). This is the one password you must memorize.
2Enable two-factor authentication on your password manager account. Use a hardware key if possible.
3Set up emergency access so a trusted person can retrieve your vault if something happens to you.
4Run the built-in security audit periodically. Most managers flag reused, weak, or breached passwords.
5Never store your master password digitally. Write it down and keep it in a physical safe until memorized.

10. Two-Factor Authentication: The Essential Second Layer

Even the strongest password can be compromised through phishing, malware, or server-side breaches. Two-factor authentication (2FA) adds a second verification step that an attacker cannot bypass with just the password. According to Google, enabling 2FA blocks over 99% of automated attacks.

2FA Methods Ranked by Security

MethodSecurity LevelProsCons
Hardware key (FIDO2/WebAuthn)HighestPhishing-proof, no shared secretsPhysical device cost, can be lost
TOTP app (Google Authenticator, Authy)HighFree, works offline, widely supportedPhishable, seed can be extracted
Push notification (Duo, MS Authenticator)HighEasy to use, shows login contextRequires internet, fatigue attacks
SMS one-time codeModerateUniversal, no app neededSIM swap attacks, SS7 vulnerabilities
Email one-time codeLow-ModerateNo app or device neededEmail compromise defeats it

For maximum security, use a FIDO2 hardware key (YubiKey, Google Titan) as your primary 2FA method and a TOTP app as backup. NIST classifies SMS as a "restricted" authenticator due to known vulnerabilities and recommends app-based or hardware methods instead.

Developer tip: When implementing 2FA in your application, support WebAuthn/FIDO2 as the primary method. It is the only 2FA method that is inherently phishing-resistant because the browser cryptographically binds the authentication to the correct domain.

11. Using Our Online Password Generator

Our free online password generator creates cryptographically secure random passwords directly in your browser. No passwords are sent to any server. The generator uses the Web Crypto API (crypto.getRandomValues) to ensure true cryptographic randomness.

  • Configurable length from 4 to 128 characters
  • Toggle uppercase, lowercase, digits, and symbols independently
  • Exclude ambiguous characters (0/O, 1/l/I) for readability
  • Real-time entropy calculation and strength indicator
  • One-click copy to clipboard
  • Runs entirely in the browser with no server communication
Try the Password Generator Tool

Frequently Asked Questions

How long should a password be in 2024-2025?
For randomly generated passwords, 16 characters with mixed character types (uppercase, lowercase, digits, symbols) provides over 105 bits of entropy, which is more than sufficient for any use case. NIST SP 800-63B requires a minimum of 8 characters but recommends much longer. For passphrases, 5-6 randomly selected words from a large word list provides comparable security. If you are using a password manager (which you should be), there is no reason not to use 16-20 character random passwords for everything.
Is a random password generator safe to use online?
A well-built online password generator that uses the Web Crypto API (crypto.getRandomValues) generates passwords entirely in your browser. The password never leaves your device and is never transmitted to any server. Our password generator works this way. However, you should verify this by checking the network tab in your browser developer tools. Avoid any generator that requires you to click "generate" and waits for a server response, as this means the password was generated server-side.
What is the difference between a random password and a passphrase?
A random password uses individual characters (letters, digits, symbols) chosen randomly, like "k9$Bm2!zYp@W". A passphrase uses randomly selected whole words, like "pencil tornado marble silk". Random passwords have higher entropy per character (6.57 bits vs 4.70 bits for lowercase), making them shorter for the same security level. Passphrases are easier to memorize and type but longer. Use random passwords when a password manager handles storage, and passphrases when you need to remember and type the password yourself.
How often should I change my passwords?
According to NIST SP 800-63B (2024), you should NOT change passwords on a regular schedule. Forced periodic rotation leads to predictable password mutations that reduce security. Change a password only when there is a specific reason: you suspect it has been compromised, it appears in a data breach database, you shared it with someone, or the service reports a security incident. If you use unique random passwords from a generator, the only reason to change one is evidence of compromise.
Can a quantum computer crack my password?
Quantum computers using Grover algorithm can reduce the effective entropy of a password by half (searching in square root of the keyspace). A 128-bit password would have 64 bits of effective quantum security. At 16 characters with full ASCII (105 bits), you would still have roughly 52 bits of quantum security, which is sufficient. For long-term security, use 20+ character passwords (131+ bits, 65+ quantum bits). However, practical large-scale quantum computers capable of running Grover at this scale are still years away.
Should I use special characters in my password?
If your password is randomly generated, including special characters increases the character pool from 62 (alphanumeric) to 95 (full ASCII), adding about 0.62 bits of entropy per character. At 16 characters, that is roughly 10 extra bits of entropy. So yes, include them. However, if you are choosing between a 12-character password with special characters and a 16-character alphanumeric password, the 16-character one is stronger (95.3 bits vs 78.8 bits). Length always beats complexity.
What is the strongest possible password?
The strongest password is one that is as long as the service allows (up to 64-128 characters), uses all available character types (full ASCII or Unicode), is generated by a cryptographically secure random number generator, is unique to a single account, and is stored in an encrypted password manager. In practice, a 20-character random password with full ASCII (131 bits of entropy) exceeds the security level of 128-bit AES encryption keys and is more than strong enough for any foreseeable threat.
Are password generators better than making up my own password?
Yes, dramatically. Research consistently shows that human-chosen passwords have far lower effective entropy than their length and character set would suggest. Humans use dictionary words, names, dates, keyboard patterns, and predictable substitutions. A study by Carnegie Mellon University found that passwords created under strict complexity rules were only marginally harder to crack than those with no rules at all. A random generator eliminates all human bias and achieves the theoretical maximum entropy for any given length and character set.

Generate a Secure Password Now

Use our free online password generator to create cryptographically secure random passwords, entirely in your browser.

Try the Password Generator Tool
𝕏 Twitterin LinkedIn
Var dette nyttig?

Hold deg oppdatert

Få ukentlige dev-tips og nye verktøy.

Ingen spam. Avslutt når som helst.

Try These Related Tools

🔑Password Generator#Hash Generator🔒Bcrypt Hash Generator

Related Articles

Passordstyrke-krav 2025: NIST-retningslinjer og beste praksis

Moderne passordkrav basert på NIST SP 800-63B.

bcrypt vs Argon2 vs scrypt: Passord-hashing 2026

Sammenlign bcrypt, Argon2id og scrypt.

SSH Keygen: Ed25519 vs RSA Guide

Generer SSH-nøkler med ssh-keygen. Sammenligning Ed25519 vs RSA og beste praksis.