Skip to content

Commit

Permalink
Merge pull request #878 from djv554/main
Browse files Browse the repository at this point in the history
Added a password strength checker
  • Loading branch information
UTSAVS26 authored Oct 28, 2024
2 parents a1ccc15 + cd87acf commit d9c978f
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Cybersecurity_Tools/Password Strength Checker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## **Password Strength Checker**

### 🎯 **Goal**

The goal of this code is to create a simple password strength checker which provides feedback to the user on how the password can be improved.

### 🧾 **Description**

The program evaluates the strength of a password provided by the user. It assesses various criteria such as length, character types, and common patterns to give users personalized feedback and tips for improving their passwords. The application aims to help users create more secure passwords, thus enhancing their overall online security.

Key Features:

- Comprehensive Password Evaluation: The tool checks for various criteria such as length, use of lowercase and uppercase letters, digits, and special characters to evaluate password strength.
- Feedback and Suggestions: After analyzing the password, the program provides detailed feedback, including tips on how to improve password strength based on the specific weaknesses identified.
- Repetition and Sequence Detection: The program detects repeated characters and simple sequences (like "1234" or "abcd") that can make a password easier to guess, providing users with alerts to avoid these patterns. If a user inputs a password that is too common, it alerts them and suggests a more unique alternative.


### 📚 **Libraries Needed**

To run the Password Strength Checker, ensure you have the following libraries installed:

- `re`: This is a built-in Python library for regular expressions, used to check password criteria.
- `ipywidgets`: This library is used for creating interactive widgets in Jupyter Notebooks.

### **How to run the code**

- Install the necessary libraries.
- Launch Jupyter Notebook in your terminal or Anaconda prompt by typing jupyter notebook.
- Copy the provided password strength checker code into a new cell in the Jupyter Notebook.
- Execute the cell. The program will display tips for creating a strong password.
- When prompted, enter a password to check its strength. The program will evaluate the password and provide overall feedback along with personalized improvement suggestions.

### 📢 **Conclusion**

The Password Strength Checker is a simple yet effective tool for promoting better password practices among users. By evaluating common vulnerabilities and providing constructive feedback, the program encourages users to create stronger passwords, thereby enhancing their security in digital spaces.

**Deanne Vaz**
[GitHub](https://github.com/djv554) | | [LinkedIn](https://www.linkedin.com/in/deanne-vaz/)

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import re

# A simplified list of common passwords for demonstration purposes
COMMON_PASSWORDS = ['123456', 'password', '123456789', 'qwerty', 'abc123', 'password1']

# Function to evaluate the strength of a password and provide improvement tips
def check_password_strength(password):
score = 0 # Initialize the score for password strength
feedback = [] # List to store feedback messages

# Check the length of the password
if len(password) >= 12:
score += 2 # Strong score for long passwords
elif len(password) >= 8:
score += 1
else:
feedback.append("Your password is too short. It should have at least 8 characters.")

# Check for lowercase letters
if re.search("[a-z]", password):
score += 1
else:
feedback.append("Consider adding some lowercase letters to strengthen your password.")

# Check for uppercase letters
if re.search("[A-Z]", password):
score += 1
else:
feedback.append("Adding uppercase letters can enhance your password's strength.")

# Check for digits
if re.search("[0-9]", password):
score += 1
else:
feedback.append("Don't forget to include numbers to make your password stronger.")

# Check for special characters
if re.search("[@#$%^&*!]", password):
score += 1
else:
feedback.append("Including special characters (like @, #, $, etc.) can greatly improve security.")

# Check if the password is too common
if password in COMMON_PASSWORDS:
feedback.append("Warning: This password is quite common. Choose something more unique.")
score -= 2 # Penalize common passwords

# Detect repeated characters (e.g., "aaa", "111")
if re.search(r'(.)\1{2,}', password):
feedback.append("Try to avoid repeated characters like 'aaa'. They can weaken your password.")
score -= 1

# Detect simple sequences like "abcd" or "1234"
if re.search(r'(?:0123|1234|2345|abcd|qwert)', password.lower()):
feedback.append("Avoid simple sequences (like '1234' or 'abcd') that are easy to guess.")
score -= 1

# Provide overall feedback based on the score
if score >= 5:
overall_feedback = "Awesome! Your password is strong."
elif 3 <= score < 5:
overall_feedback = "Not bad! Your password is medium-strength. A few improvements could help."
else:
overall_feedback = "Oh no! Your password is weak. Please consider changing it for better security."

return overall_feedback, feedback

# Provide the user with tips for creating a strong password
print("Tips for Creating a Strong Password:")
print("- At least 12 characters long.")
print("- Include a mix of uppercase and lowercase letters.")
print("- Use numbers and special characters (e.g., @, #, $, etc.).")
print("- Avoid common passwords and sequences (like '1234', 'abcd').")
print("- Don't use easily guessable information (like your name or birthday).")

# Prompt the user to input a password in the Jupyter notebook
password = input("\nEnter a password to check its strength: ")
overall_feedback, improvement_tips = check_password_strength(password)

# Display overall feedback and improvement tips in the notebook output
print("\nPassword Strength Feedback:")
print(overall_feedback) # Print the overall feedback

# Print personalized improvement tips
if improvement_tips:
print("\nSuggestions to Improve Your Password:")
for tip in improvement_tips:
print(f"- {tip}") # Print each improvement tip
else:
print("Your password meets all the criteria!")
2 changes: 2 additions & 0 deletions Project-Structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@
* [Predict](Cybersecurity_Tools/PDF_Malware_Detection/predict.py)
* Packet-Sniffer
* [Packetsniffer](Cybersecurity_Tools/Packet-sniffer/packetsniffer.py)
* Password Strength Checker
* [Password Strength Checker](Cybersecurity_Tools/Password%20Strength%20Checker/password_strength_checker.py)
* Phishing Detection Tool
* [Phishing Detection](Cybersecurity_Tools/Phishing%20detection%20tool/phishing_detection.py)
* Pixel Decoder
Expand Down

0 comments on commit d9c978f

Please sign in to comment.