Skip to content
🛠️ToolsShed

Secure Passphrase Generator

Generate memorable Diceware-style passphrases with entropy estimation.

38

About this tool

A passphrase is a sequence of unrelated words joined together to form a memorable yet secure authentication credential. The Secure Passphrase Generator creates passphrases using the Diceware method, a proven cryptographic technique that leverages the human brain's natural strength in remembering word sequences rather than random character combinations. Unlike traditional passwords cluttered with special characters, Diceware passphrases deliver exceptional security through simplicity—making them ideal for long-term credentials like password manager master passwords, banking accounts, and high-value secrets.

Using the generator is straightforward: select how many words you want (typically 5 to 6 for most purposes), choose a separator character, and toggle capitalization to suit your needs. The tool instantly calculates the entropy—the statistical measure of password strength—showing you exactly how much security your passphrase provides in bits. Each word added increases entropy logarithmically; for example, a 4-word passphrase provides ~51 bits of entropy while a 6-word passphrase jumps to ~77 bits, which exceeds modern security recommendations.

Diceware passphrases work because they combine genuine randomness (from your computer's cryptographically secure random number generator) with a large wordlist (typically 7,776 words), ensuring attackers cannot guess or predict the outcome. Many systems demand special characters or numbers; rather than weaken your passphrase with predictable substitutions, generate a phrase here and store it in a password manager if your account requires additional constraints. This tool is especially valuable for developers, security professionals, and anyone managing sensitive credentials who values memorability alongside mathematical certainty.

Frequently Asked Questions

Code Implementation

import secrets
import math

# A small built-in word list; replace with a full EFF large wordlist in production.
WORDLIST = [
    "apple", "brave", "crane", "drift", "eagle", "flame", "grace", "hover",
    "ivory", "jewel", "knack", "lunar", "maple", "noble", "ocean", "pearl",
    "quilt", "raven", "stone", "tiger", "umbra", "vivid", "waltz", "xenon",
    "yacht", "zonal", "amber", "blaze", "crisp", "delta", "ember", "frost",
    "globe", "haste", "index", "joust", "karma", "lance", "marsh", "nerve",
    "ozone", "pilot", "query", "ridge", "storm", "trove", "ultra", "vigor",
    "width", "xylem", "yearn", "zesty",
]

def generate_passphrase(
    word_count: int = 4,
    separator: str = "-",
    capitalize: bool = False,
    append_number: bool = False,
) -> str:
    words = [secrets.choice(WORDLIST) for _ in range(word_count)]
    if capitalize:
        words = [w.capitalize() for w in words]
    phrase = separator.join(words)
    if append_number:
        phrase += separator + str(secrets.randbelow(9000) + 1000)
    return phrase

def passphrase_entropy(word_count: int, wordlist_size: int) -> float:
    """Bits of entropy: log2(wordlist_size ^ word_count)"""
    return word_count * math.log2(wordlist_size)


if __name__ == "__main__":
    for _ in range(5):
        phrase = generate_passphrase(4, "-", capitalize=True, append_number=True)
        print(phrase)
    bits = passphrase_entropy(4, len(WORDLIST))
    print(f"Entropy with {len(WORDLIST)}-word list, 4 words: {bits:.1f} bits")

Comments & Feedback

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