Skip to content
Laviyx Learn

Try

Mini project

Password Generator and Strength Checker in Python

A Python tool that creates strong random passwords with the secrets module and rates any password's strength using length, character variety, entropy and a list of common passwords.

Beginner 1 week 1 studentUpdated

PythonsecretsreTkinter (optional)

The problem

Weak and reused passwords are one of the most common ways accounts get broken into. People need an easy way to make strong passwords and to understand why a password is weak. This tool does both, and teaches the security ideas behind it.

Features to build

  • Generate passwords of a chosen length with options for lowercase, uppercase, digits and symbols
  • Use the secrets module, which is designed for security, never the random module
  • Guarantee at least one character from each chosen group
  • Generate readable passphrases from a word list, such as river-planet-mango-42
  • Check any password: length, character groups, repeated or sequential characters like aaa or 1234
  • Reject passwords found in a list of common passwords
  • Show an estimated entropy in bits and a clear rating: weak, fair, strong or very strong, with tips

Build plan

  1. 1

    Generate safely

    Build the character pool from the chosen options and pick each character with secrets.choice. Pick one from each chosen group first, then shuffle with secrets.SystemRandom().shuffle.

  2. 2

    Add passphrases

    Load a word list from a text file and join 4 or more randomly chosen words with a separator, plus an optional number.

  3. 3

    Write the checks

    Write one small function per rule (length, groups, repeats, sequences, common list) that returns a message when the rule fails.

  4. 4

    Estimate entropy

    For random passwords, entropy = length × log2(pool size). Explain that this is only an estimate, and that human-chosen passwords are weaker than the formula suggests.

  5. 5

    Present the result

    Combine the checks into a rating and print clear tips. Never save or log the passwords that are checked.

Learn these first

Each part of the project is taught in one of these free lessons.

Make it stand out

  • A simple Tkinter window with a copy-to-clipboard button
  • Check whether a password appears in known data breaches using a k-anonymity API, sending only the first 5 characters of its SHA-1 hash
  • Unit tests with pytest for every rule

Viva and interview questions

Try to answer each one aloud before you open it.

  • Why use the secrets module instead of random?

    The random module uses the Mersenne Twister algorithm, which is fast but predictable: after seeing enough outputs, the next ones can be worked out. secrets uses the operating system's cryptographically secure random generator, which is designed to be unpredictable.

  • What is password entropy?

    A measure of how hard a password is to guess, in bits. A password chosen randomly from a pool of N characters with length L has about L × log2(N) bits. Each extra bit doubles the number of guesses needed.

  • Why is a long passphrase often better than a short complex password?

    Length adds entropy quickly. Four random words from a 7,776-word list give about 51.7 bits and are easy to remember, while an 8-character password with all symbol types has about 52 bits but is hard to remember, so people reuse or write it down.

  • How should a website store passwords?

    Never as plain text or reversible encryption. It should store a salted hash made with a slow password-hashing function such as bcrypt, scrypt or Argon2, so a stolen database cannot easily be turned back into passwords.

What to put in your project report

  1. Abstract: the problem, your solution and the result in one paragraph.
  2. Introduction and problem statement: who has the problem and why it matters.
  3. Requirements: the features (functional) and qualities such as speed and security (non-functional).
  4. Design: architecture diagram, database tables or data flow, and screen layouts.
  5. Implementation: the main modules and the most interesting code, explained.
  6. Testing: the test cases you ran, with inputs, expected and actual results.
  7. Results: screenshots or numbers that show the project working.
  8. Conclusion and future scope: what you achieved and what you would add next.

Your college may give its own format. Follow that first, and use this list to check nothing is missing.

All project ideas →