Skip to content

Commit

Permalink
Update encryptor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hackergandhi authored Aug 17, 2024
1 parent 03661ab commit efb3557
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main/encryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
sys.dont_write_bytecode = True

from cryptography.fernet import Fernet
import re

def generate_key():
"""
Expand Down Expand Up @@ -29,3 +30,23 @@ def decrypt_message(encrypted_message: bytes, key: bytes) -> str:
f = Fernet(key)
return f.decrypt(encrypted_message).decode()

def validate_password(password: str) -> bool:
"""
Validates the password to ensure it meets certain criteria.
"""
if len(password) < 8:
print("Password should be at least 8 characters long.")
return False
if not re.search("[a-z]", password):
print("Password should contain at least one lowercase letter.")
return False
if not re.search("[A-Z]", password):
print("Password should contain at least one uppercase letter.")
return False
if not re.search("[0-9]", password):
print("Password should contain at least one number.")
return False
if not re.search("[!@#$%^&*(),.?\":{}|<>]", password):
print("Password should contain at least one special character.")
return False
return True

0 comments on commit efb3557

Please sign in to comment.