Skip to content

Commit

Permalink
Update passcheck.py
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSaikat authored Jul 14, 2024
1 parent cf221b2 commit 776d024
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions PassCheck/passcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,42 @@
from colorama import Fore, Style, init
import pyfiglet

# Initialize colorama
init(autoreset=True)

def password_strength(password):
length = len(password)
complexity = 0
suggestions = []

# Length check
if length >= 8:
complexity += 1
else:
suggestions.append("🔸 " + Fore.YELLOW + "Make your password at least 8 characters long.")

# Check for lowercase letters
if re.search(r"[a-z]", password):
complexity += 1
else:
suggestions.append("🔸 " + Fore.YELLOW + "Include at least one lowercase letter.")

# Check for uppercase letters
if re.search(r"[A-Z]", password):
complexity += 1
else:
suggestions.append("🔸 " + Fore.YELLOW + "Include at least one uppercase letter.")

# Check for digits
if re.search(r"\d", password):
complexity += 1
else:
suggestions.append("🔸 " + Fore.YELLOW + "Include at least one digit.")

# Check for special characters
if re.search(r"[!@#$%^&*(),.?\":{}|<>]", password):
complexity += 1
else:
suggestions.append("🔸 " + Fore.YELLOW + "Include at least one special character (e.g., !, @, #, $, etc.).")

# Check for sequences of the same character
if re.search(r"(.)\1{2,}", password):
complexity -= 1
suggestions.append("🔸 " + Fore.YELLOW + "Avoid sequences of the same character (e.g., 'aaa').")

# Feedback on password strength
if complexity == 0:
strength = "Very Weak"
color = Fore.RED
Expand Down Expand Up @@ -95,10 +87,10 @@ def main():
print(Fore.CYAN + "Goodbye! 👋")
break

print() # Add a blank line after entering the password
print()

strength, suggestions = password_strength(user_password)
print(strength + "\n") # Add a blank line after displaying password strength
print(strength + "\n")

if suggestions:
print("Suggestions to improve your password:")
Expand All @@ -107,7 +99,7 @@ def main():
else:
print(Fore.GREEN + "✅ Your password is strong enough.")

print() # Add a blank line for separation between password checks
print()

if __name__ == "__main__":
main()
Expand Down

0 comments on commit 776d024

Please sign in to comment.