๐ŸŽ™ Free live masterclass ยท Sun, 29 Nov, 7:00 pm IST ยท Java Full Stack roadmap Register free โ†’
Skills101

Password generator and strength checker

Generate strong passwords and score how strong an existing password is, with clear tips to improve it.

Beginnerโฑ 3โ€“4 hours๐Ÿชœ 7 stepsPythonsecrets

What you'll learn

  • โ—†Why secrets is safer than random for passwords
  • โ—†String handling and character classes
  • โ—†Writing simple scoring rules and tests

What you'll build

  • โœ“Generate a password of chosen length with chosen character types
  • โœ“Generate memorable passphrases from a word list
  • โœ“Strength score 0โ€“4 with reasons
  • โœ“Copies the password to the clipboard

Step-by-step guide

  1. 1

    Generate with secrets

    Build the alphabet from string.ascii_lowercase, ascii_uppercase, digits and punctuation, then use secrets.choice in a loop.

  2. 2

    Guarantee every chosen type

    Pick at least one character from each selected type first, fill the rest, then shuffle with secrets.SystemRandom().shuffle.

  3. 3

    Add passphrases

    Load a word list (for example the EFF short word list), pick 4โ€“6 words with secrets.choice and join them with "-".

  4. 4

    Score strength

    Give points for length (12+, 16+), for each character type and subtract for common patterns like "1234", "password" or repeated characters.

  5. 5

    Explain the score

    Return a list of reasons ("Add a symbol", "Avoid common words") alongside the score and print them.

  6. 6

    Write tests

    Use pytest to check the generator always includes each selected type and that "password123" scores low.

  7. 7

    Copy to clipboard

    pip install pyperclip and call pyperclip.copy(pw) after generating.

๐Ÿš€ Make it stand out

  • +Check a password against breach data with the Have I Been Pwned range API (k-anonymity, only 5 hash characters are sent)
  • +Add a Tkinter GUI
  • +Estimate crack time from the entropy