From 5c12671766b863f73b91743da75c99b1b13f9af7 Mon Sep 17 00:00:00 2001 From: Tyler Date: Fri, 20 Feb 2026 11:41:31 +0300 Subject: [PATCH 1/4] Initil commit. This is a script used to either generate a password or check strength of your password. --- securepass/README.md | 117 ++++++++++++++++++++++++++++++++++++++ securepass/password.py | 126 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 securepass/README.md create mode 100644 securepass/password.py diff --git a/securepass/README.md b/securepass/README.md new file mode 100644 index 0000000..e79364b --- /dev/null +++ b/securepass/README.md @@ -0,0 +1,117 @@ +# Secure Password Manager + +A Python utility for generating secure passwords and checking the strength of existing passwords. + +## Features + +- **Password Generator**: Create secure passwords with multiple options + - Mix of numbers, letters, and symbols (Recommended) + - Numbers only + - Letters only + - Symbols only + - Customizable length (4-20 characters) + +- **Password Strength Checker**: Analyze password quality and get recommendations + - Check password length + - Analyze character composition (uppercase, lowercase, numbers, symbols) + - Receive suggestions for improvement + - Detailed password report + +## Installation + +No external dependencies are required. This script uses only Python standard library modules. + +```bash +# Clone or download the repository +# Navigate to the securepass directory +cd securepass + +# Run the script +python password.py +``` + +## Usage + +Run the script and follow the interactive prompts: + +```bash +python password.py +``` + +### Main Menu + +You'll be presented with two options: +1. **Generate a secure password** - Create a new password with custom specifications +2. **Check strength of my password** - Analyze an existing password + +### Generate Password Workflow + +1. Select the password type (1-4) +2. Enter desired length (4-20 characters) +3. View your generated password +4. Optionally get a detailed password report + +### Check Password Strength Workflow + +1. Enter the password you want to check +2. Receive a detailed report with recommendations + +## Example Output + +``` +What would you like to do: +1 Generate a secure password +2 Check strength of my password +> 1 + +Choose password type: +1 Mix of numbers, letters and symbols (Recommended) +2 Numbers only password +3 Letters only password +4 Symbols only password +> 1 + +Enter your desired length (between 4 and 20): 12 +Here is your password: aB3!xK9$mQ2@ + +Would you like a report for this password? (y/n): y +The password has a length of 12 characters, which meets or exceeds the recommended 8. +It has 2 uppercase letter(s), 2 lowercase letter(s), 3 number(s), and 3 symbol(s). +This password has a good mix of character types. +``` + +## Password Strength Criteria + +The password strength checker evaluates: + +- **Length**: Recommends a minimum of 8 characters +- **Character Diversity**: Checks for presence of: + - Uppercase letters + - Lowercase letters + - Numbers + - Symbols + +## Functions + +- `generate_number_only(length)` - Generates password with digits only +- `generate_letters_only(length)` - Generates password with letters only +- `generate_symbols_only(length)` - Generates password with symbols only +- `mix_of_all(length)` - Generates password with mix of all character types +- `password_report(password)` - Analyzes password strength and returns report + +## Requirements + +- Python 3.x +- No external packages required + +## Best Practices + +- Use "Mix of numbers, letters and symbols" for the strongest passwords +- Maintain a minimum length of 12 characters for sensitive accounts +- Store generated passwords securely (consider using a password manager) +- Regularly update passwords for important accounts +- Never share passwords or store them in plain text + +## License + +This project is part of the Python-Projects repository by Grow-with-Open-Source. diff --git a/securepass/password.py b/securepass/password.py new file mode 100644 index 0000000..e617355 --- /dev/null +++ b/securepass/password.py @@ -0,0 +1,126 @@ +import random +import string + + +def main(): + while True: + option = input( + "What would you like to do:\n" + "1 Generate a secure password\n" + "2 Check strength of my password\n> " + ) + if option not in ("1", "2"): + print("Please choose 1 or 2.") + continue + break + + if option == "1": + while True: + try: + choice = int( + input( + "Choose password type:\n" + "1 Mix of numbers, letters and symbols (Recommended)\n" + "2 Numbers only password\n" + "3 Letters only password\n" + "4 Symbols only password\n> " + ) + ) + length = int(input("Enter your desired length (between 4 and 20): ")) + except ValueError: + print("Invalid input, enter numbers only.") + continue + + if choice not in (1, 2, 3, 4) or length not in range(4, 21): + print("Invalid input, try again.") + continue + break + + if choice == 1: + passwd = mix_of_all(length) + elif choice == 2: + passwd = generate_number_only(length) + elif choice == 3: + passwd = generate_letters_only(length) + else: + passwd = generate_symbols_only(length) + + print("Here is your password:", passwd) + + if input("Would you like a report for this password? (y/n): ").lower() == "y": + print(password_report(passwd)) + + else: # option == "2" + existing = input("Enter the password you want to check: ") + print(password_report(existing)) + + +def generate_number_only(length): + digits = string.digits + return "".join(random.choice(digits) for _ in range(length)) + + +def generate_letters_only(length): + letters = string.ascii_letters + return "".join(random.choice(letters) for _ in range(length)) + + +def generate_symbols_only(length): + symbols = "!@#$%^&*()-_=+[]{};:,.<>?/\\|" + return "".join(random.choice(symbols) for _ in range(length)) + + +def mix_of_all(length): + pool = string.ascii_letters + string.digits + "!@#$%^&*()-_=+[]{};:,.<>?/\\|" + return "".join(random.choice(pool) for _ in range(length)) + + +def password_report(password: str) -> str: + recommended_length = 8 + + length = len(password) + upper = sum(1 for ch in password if ch.isupper()) + lower = sum(1 for ch in password if ch.islower()) + digits = sum(1 for ch in password if ch.isdigit()) + symbols = sum(1 for ch in password if not ch.isalnum()) + + parts = [] + + # Length report + diff = recommended_length - length + if diff > 0: + parts.append( + f"The password has a length of {length} characters, {diff} less than the recommended {recommended_length}." + ) + else: + parts.append( + f"The password has a length of {length} characters, which meets or exceeds the recommended {recommended_length}." + ) + + # Composition report + parts.append( + f"It has {upper} uppercase letter(s), {lower} lowercase letter(s), {digits} number(s), and {symbols} symbol(s)." + ) + + suggestions = [] + if upper == 0: + suggestions.append("add at least one uppercase letter") + if lower == 0: + suggestions.append("add at least one lowercase letter") + if digits == 0: + suggestions.append("add at least one number") + if symbols == 0: + suggestions.append("add a symbol for extra strength") + + if suggestions: + parts.append( + "To improve this password, you could " + ", ".join(suggestions) + "." + ) + else: + parts.append("This password has a good mix of character types.") + + return " ".join(parts) + + +if __name__ == '__main__': + main() From 9ef154864cf454c08c3bc2a78973ebf9e538b917 Mon Sep 17 00:00:00 2001 From: Tyler Date: Fri, 20 Mar 2026 07:20:59 +0300 Subject: [PATCH 2/4] Update securepass/password.py Co-authored-by: Shamith Nakka --- securepass/password.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/securepass/password.py b/securepass/password.py index e617355..b68678c 100644 --- a/securepass/password.py +++ b/securepass/password.py @@ -79,10 +79,16 @@ def password_report(password: str) -> str: recommended_length = 8 length = len(password) - upper = sum(1 for ch in password if ch.isupper()) - lower = sum(1 for ch in password if ch.islower()) - digits = sum(1 for ch in password if ch.isdigit()) - symbols = sum(1 for ch in password if not ch.isalnum()) + upper = lower = digits = symbols = 0 + for letter in password: + if letter.isupper(): + upper += 1 + elif letter.islower(): + lower += 1 + elif letter.isdigit(): + digits += 1 + else: + symbols += 1 parts = [] From 18ec27d64a77db32166a99b86afe9d9aa9da5600 Mon Sep 17 00:00:00 2001 From: Tyler Date: Fri, 20 Mar 2026 07:21:14 +0300 Subject: [PATCH 3/4] Update securepass/password.py Co-authored-by: Shamith Nakka --- securepass/password.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/securepass/password.py b/securepass/password.py index b68678c..9dc51f9 100644 --- a/securepass/password.py +++ b/securepass/password.py @@ -3,16 +3,15 @@ def main(): - while True: + option = "" + while option not in ("1", "2"): option = input( "What would you like to do:\n" "1 Generate a secure password\n" - "2 Check strength of my password\n> " + "2 Check the strength of my password\n> " ) if option not in ("1", "2"): print("Please choose 1 or 2.") - continue - break if option == "1": while True: From 2ab490a508450c5cde75a0fdbf50d4bc0660ca68 Mon Sep 17 00:00:00 2001 From: Tyler Date: Fri, 20 Mar 2026 07:21:30 +0300 Subject: [PATCH 4/4] Update securepass/password.py Co-authored-by: Shamith Nakka --- securepass/password.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/securepass/password.py b/securepass/password.py index 9dc51f9..f663f47 100644 --- a/securepass/password.py +++ b/securepass/password.py @@ -14,7 +14,9 @@ def main(): print("Please choose 1 or 2.") if option == "1": - while True: + choice = None + length = None + while choice not in (1, 2, 3, 4): try: choice = int( input( @@ -25,15 +27,17 @@ def main(): "4 Symbols only password\n> " ) ) + if choice not in (1, 2, 3, 4): + print("Invalid choice, try again.") + except ValueError: + print("Invalid input, enter numbers only.") + while length not in range(4, 21): + try: length = int(input("Enter your desired length (between 4 and 20): ")) + if length not in range(4, 21): + print("Invalid length, try again.") except ValueError: print("Invalid input, enter numbers only.") - continue - - if choice not in (1, 2, 3, 4) or length not in range(4, 21): - print("Invalid input, try again.") - continue - break if choice == 1: passwd = mix_of_all(length)