πŸ› οΈToolsShed

Password Generator

Generate strong, secure passwords with customizable options.

6128

Password Generator creates cryptographically secure random passwords using your browser's built-in random number generator (the Web Crypto API). This means the passwords are generated entirely on your device β€” they are never sent over the network or stored anywhere, making this tool safe to use even for highly sensitive accounts.

Configure the length (8–128 characters) and character set to match the requirements of the service you are creating an account for. Most security experts recommend passwords of at least 16 characters using a mix of uppercase letters, lowercase letters, numbers, and symbols. Longer passwords are exponentially harder to crack: a 16-character random password is astronomically more secure than a strong-looking but memorable word-based password.

A password manager is the best companion to a password generator. Tools like Bitwarden, 1Password, or KeePass let you generate and store a unique, random password for every site without needing to remember them. If a site you use gets breached, only that one password is exposed β€” your other accounts remain safe. Never reuse passwords across multiple services.

Frequently Asked Questions

Code Implementation

import secrets
import string

def generate_password(
    length: int = 16,
    use_upper: bool = True,
    use_lower: bool = True,
    use_digits: bool = True,
    use_symbols: bool = True,
) -> str:
    """Generate a cryptographically secure random password."""
    charset = ""
    required = []

    if use_lower:
        charset += string.ascii_lowercase
        required.append(secrets.choice(string.ascii_lowercase))
    if use_upper:
        charset += string.ascii_uppercase
        required.append(secrets.choice(string.ascii_uppercase))
    if use_digits:
        charset += string.digits
        required.append(secrets.choice(string.digits))
    if use_symbols:
        symbols = "!@#$%^&*()-_=+[]{}|;:,.<>?"
        charset += symbols
        required.append(secrets.choice(symbols))

    if not charset:
        raise ValueError("At least one character type must be selected")

    # Fill the rest of the password
    remaining = [secrets.choice(charset) for _ in range(length - len(required))]
    password_list = required + remaining

    # Shuffle to avoid predictable positions
    secrets.SystemRandom().shuffle(password_list)
    return "".join(password_list)

# Examples
print(generate_password(16))
print(generate_password(24, use_symbols=False))
print(generate_password(8, use_upper=False, use_symbols=False))

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.