-
Notifications
You must be signed in to change notification settings - Fork 81
Password Generator & Checker #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5c12671
Initil commit. This is a script used to either generate a password or…
Lampard7crypt 9ef1548
Update securepass/password.py
Lampard7crypt 18ec27d
Update securepass/password.py
Lampard7crypt 2ab490a
Update securepass/password.py
Lampard7crypt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Lampard7crypt marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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()) | ||
|
Lampard7crypt marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.