Formula Forge Logo
Formula Forge

Generate Random Passwords Safely: Strength, Entropy, and Storage

Passwords are the first line of defense for digital accounts, yet weak passwords remain a leading cause of security breaches. Generating strong, random passwords is essential, but it's only part of the solution. Understanding password strength, entropy, secure generation methods, and proper storage practices creates a comprehensive security strategy that protects against common attacks.

A strong password combines sufficient length, high entropy (true randomness), and uniqueness across accounts. Modern password attacks leverage dictionaries, common patterns, and leaked password databases. Randomly generated passwords resist these attacks because they lack predictable patterns that attackers exploit.

Generate secure random passwords using our Random Number Generator as part of a comprehensive password strategy, but remember: password generation is only one component of security.

What "Strong" Really Means

Password strength isn't about complexity tricks—it's about entropy and length. Understanding these concepts helps you evaluate and generate truly strong passwords.

Entropy: The Measure of Randomness

Entropy measures password unpredictability in bits. Higher entropy means more guesses required to crack:

Entropy Calculation:

  • Character set size: Number of possible characters
  • Password length: Number of characters
  • Entropy = length × log₂(character_set_size)

Examples:

  • 8-character password from 26 lowercase letters: 8 × log₂(26) ≈ 37 bits
  • 12-character password from 94 printable ASCII: 12 × log₂(94) ≈ 78 bits
  • 16-character password from 94 characters: 16 × log₂(94) ≈ 104 bits

Security Thresholds:

  • Minimum: 64 bits (resistant to online attacks)
  • Good: 80+ bits (resistant to offline attacks)
  • Strong: 100+ bits (long-term security)

Length Over Cleverness

Long passwords beat short complex ones:

Comparison:

  • P@ssw0rd! (10 chars, predictable): ~30 bits entropy
  • correct horse battery staple (28 chars, random words): ~110 bits entropy

The second password is stronger despite being simpler because it's longer and randomly selected.

Recommendation: Prefer 16-24 character minimums for high-value accounts. Longer passwords (25+ characters) provide additional security margin.

Password Generation Methods

Different generation methods offer different balances of strength, memorability, and usability.

Cryptographically Secure Random Generators

Method: Use CSPRNGs (Cryptographically Secure PRNGs) to select characters randomly.

Implementation Examples:

Python:

import secrets
import string

def generate_password(length=20):
    alphabet = string.ascii_letters + string.digits + string.punctuation
    return ''.join(secrets.choice(alphabet) for _ in range(length))

JavaScript:

function generatePassword(length = 20) {
    const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*';
    const array = new Uint8Array(length);
    crypto.getRandomValues(array);
    return Array.from(array, x => alphabet[x % alphabet.length]).join('');
}

Characteristics:

  • Maximum entropy
  • No predictable patterns
  • Requires secure storage (not memorizable at long lengths)

Passphrase Generation

Method: Select random words from large word lists (EFF word lists recommended).

Process:

  1. Use word list of 7,776+ words (EFF long list)
  2. Select 4-6 words randomly
  3. Optionally add separators or capitalization

Example: correct-horse-battery-staple (4 words, ~51 bits entropy)

Advantages:

  • More memorable than random character strings
  • Can achieve high entropy with fewer "units" to remember
  • Easier to type correctly

Implementation:

import secrets

EFF_WORD_LIST = [...]  # Load EFF word list

def generate_passphrase(word_count=4):
    words = [secrets.choice(EFF_WORD_LIST) 
             for _ in range(word_count)]
    return '-'.join(words)

Best Practices:

  • Use 4-6 words minimum
  • Use established word lists (EFF, Diceware)
  • Add separators if site policies require special characters
  • Avoid modifying words (don't add "123" or capitalize predictably)

What to Avoid

Don't Use:

  • Predictable patterns: Password123!, Summer2024!
  • Dictionary words alone: dragon, password, admin
  • Personal information: Names, birthdays, addresses
  • Common substitutions: P@ssw0rd (still predictable)
  • Short passwords: Under 12 characters
  • Reused passwords: Same password across multiple sites

Never Use:

  • Standard PRNGs (Math.random(), random.randint()) for password generation
  • Time-based seeds for security applications
  • Predictable algorithms for password generation

Storage and Management

Strong passwords are useless if stored insecurely. Proper storage practices protect passwords from theft and exposure.

Password Managers: The Gold Standard

Benefits:

  • Generate unique passwords per site
  • Encrypt passwords with strong master password
  • Sync across devices securely
  • Autofill reduces phishing risk
  • Organize passwords efficiently

Recommended Managers:

  • Bitwarden (open-source, freemium)
  • 1Password (premium, excellent UX)
  • KeePass (local storage, open-source)
  • LastPass (freemium, check recent security history)

Master Password Requirements:

  • Use strong passphrase (6+ random words)
  • Enable two-factor authentication (2FA)
  • Never reuse master password elsewhere

Secure Storage Practices

If Using Password Manager:

  • Use long, unique master password
  • Enable 2FA on password manager account
  • Use biometric unlock when available
  • Keep software updated

If Not Using Password Manager (Not Recommended):

  • Never store in plaintext files
  • Never email passwords to yourself
  • Never use browser password storage without encryption
  • Consider physical secure storage (encrypted USB, safe) for backup

Backup Strategy:

  • Export encrypted backup from password manager
  • Store in secure location (encrypted cloud or physical safe)
  • Test restore process periodically
  • Never store backups in plaintext

Recovery Codes and Backup Access

Recovery Codes:

  • Generate and store securely (password manager secure notes)
  • Store physical copy in safe location
  • Never store with passwords themselves
  • Update when password manager account changes

Emergency Access:

  • Designate trusted contact with emergency access instructions
  • Use password manager emergency access features
  • Document process without exposing passwords

Password Policies and Site Requirements

Different sites impose different requirements. Navigate these while maintaining security:

Common Requirements

Character Requirements:

  • Uppercase letters (A-Z)
  • Lowercase letters (a-z)
  • Numbers (0-9)
  • Special characters (!@#$%^&*)

Length Requirements:

  • Minimum: Often 8-12 characters
  • Maximum: Some sites limit to 16-32 characters

Working Within Constraints

Strategy 1: Meet Minimums, Exceed When Possible

  • Generate 20+ character password
  • Truncate if site has maximum length
  • Ensure truncated version still meets requirements

Strategy 2: Adapt Passphrase

  • Add required character types to random passphrase
  • Example: correct-horse-battery-staple-A1! (meets all requirements)

Strategy 3: Use Password Manager

  • Most managers adapt generation to site requirements automatically
  • Reduces manual adjustment needed

Password Rotation: When and Why

Traditional wisdom suggested frequent password rotation, but modern security guidance has evolved.

When to Rotate

Rotate Immediately:

  • Suspected compromise
  • Data breach affecting the site
  • Sharing password accidentally
  • Device loss/theft

Rotate Periodically:

  • High-value accounts (banking, email): Annually or per policy
  • Critical infrastructure: Per organizational policy
  • When required by compliance regulations

Don't Rotate:

  • Simply because time has passed (if no compromise suspected)
  • So frequently that you choose weaker passwords
  • If rotation causes you to reuse patterns

Modern Guidance

Focus on:

  • Unique, strong passwords per account
  • Two-factor authentication (2FA) where available
  • Monitoring for breaches (Have I Been Pwned)
  • Secure storage practices

Avoid:

  • Mandatory frequent rotation (causes weak password choices)
  • Predictable rotation patterns
  • Rotating without addressing root causes

Two-Factor Authentication (2FA)

2FA adds a second authentication factor, dramatically improving security even with compromised passwords.

Types of 2FA

Authenticator Apps (Recommended):

  • Google Authenticator, Authy, Microsoft Authenticator
  • Time-based one-time passwords (TOTP)
  • Works offline, more secure than SMS

Hardware Security Keys:

  • YubiKey, Titan Security Key
  • Most secure option
  • Phishing-resistant

SMS/Email Codes:

  • Less secure than authenticator apps
  • Vulnerable to SIM swapping
  • Better than no 2FA, but not ideal

Implementation Priority

Enable 2FA On:

  • Email accounts (primary recovery method)
  • Banking and financial accounts
  • Password manager
  • Social media accounts
  • Any account with sensitive data

Worked Example: Complete Password Strategy

Step 1: Generate Master Password

  • Use passphrase generator: correct-horse-battery-staple-moonlight-question
  • 6 words, ~77 bits entropy
  • Store recovery codes securely

Step 2: Set Up Password Manager

  • Install Bitwarden or 1Password
  • Set master password (passphrase above)
  • Enable 2FA on password manager account
  • Create secure backup

Step 3: Generate Unique Passwords

  • Use password manager generator: 20+ characters
  • One unique password per account
  • Let manager adapt to site requirements

Step 4: Enable 2FA Where Available

  • Start with email, banking, password manager
  • Use authenticator app (not SMS when possible)
  • Store backup codes in password manager secure notes

Step 5: Monitor for Breaches

  • Use Have I Been Pwned or password manager breach monitoring
  • Rotate compromised passwords immediately
  • Review account security annually

Conclusion

Strong password generation requires understanding entropy, using cryptographically secure methods, and implementing proper storage practices. Random passwords beat predictable patterns, length beats complexity tricks, and password managers enable practical security at scale.

Remember: password generation is only one component. Combine strong random passwords with password managers, two-factor authentication, and breach monitoring for comprehensive account security. Don't let perfect be the enemy of good—start with a password manager and 2FA on critical accounts, then expand from there.

For generating random values as part of password strategies, use our Random Number Generator, but always use cryptographically secure methods (CSPRNGs) for actual password generation, not standard PRNGs.

For more on randomness and security, explore our articles on generating random passwords safely (this article), true vs pseudo-randomness, and common RNG mistakes.

FAQs

Is a passphrase better than a random password?

For memorability, yes—if words are randomly selected from large lists. For maximum entropy in given length, random character strings win. For most users, 4-6 word passphrases provide excellent security and usability.

Should I rotate passwords regularly?

Modern guidance: rotate when compromised, not on schedule. Focus on unique strong passwords and 2FA rather than frequent rotation, which often leads to weaker password choices.

Can I write down my passwords?

Physical secure storage (encrypted, locked safe) is acceptable for backups, but password managers are superior. Never store passwords in plaintext or easily accessible locations.

What if a site doesn't allow password managers?

Some sites block autofill or have restrictive policies. Use password manager's manual copy/paste feature, or consider whether the site's security practices merit your business.

How do I know if my password was breached?

Use Have I Been Pwned or your password manager's breach monitoring. If breached, change password immediately and enable 2FA if not already enabled.

Sources

  • National Institute of Standards and Technology. "Digital Identity Guidelines: Authentication and Lifecycle Management." NIST Special Publication 800-63B, 2017.
  • Electronic Frontier Foundation. "Diceware Passphrase Home." EFF.org, 2016.
  • Bonneau, Joseph, et al. "The Science of Guessing: Analyzing an Anonymized Corpus of 70 Million Passwords." IEEE Symposium on Security and Privacy, 2012.
Try our Free Random Number Generator →
Related Articles