Skip to content

Commit

Permalink
Added a password length check (minimum length of password should be 8…
Browse files Browse the repository at this point in the history
… characters long) IMGIITRoorkee#3
  • Loading branch information
Akshat1276 committed Jan 5, 2025
1 parent bb75c6a commit ab87640
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Visit the **python** channel and ping `2Y` for assistance.
- `4`: Load an existing password file.
- `5`: Add a new password to the file.
- `6`: Retrieve a password from the file.
- `c`: Clear the CLI
- `q`: Quit the application.

---
Expand Down Expand Up @@ -139,4 +140,4 @@ Password for github is securepassword123
## Security Note

- **Keep Your Encryption Key Safe**:
The encryption key is crucial for accessing your passwords. Losing it means your passwords cannot be decrypted.
The encryption key is crucial for accessing your passwords. Losing it means your passwords cannot be decrypted.
17 changes: 13 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os #will allow user to interact with the operating system
from manager import PasswordManager
import pyperclip
import sys
Expand Down Expand Up @@ -39,7 +40,8 @@ def validate_key_loaded(pm : PasswordManager):
print("Key not loaded. Please load a key first.")
return False
return True

def clear_screen(): #Defining the clear screen function to clear the CLI.
os.system('cls' if os.name == 'nt' else 'clear') #'cls' is used to clear the terminal screen in windows, for Linux, MacOS etc. 'clear' is used
def main():
password = {
"gmail": "password1",
Expand All @@ -49,16 +51,19 @@ def main():

pm = PasswordManager()

print("""What would you like to do?
menu = """What would you like to do?
1. Create a new key
2. Load an existing key
3. Create a new password file
4. Load an existing password file
5. Add a password
6. Get a password
7. List all sites
c. Clear Screen
q. Quit
""")
"""

print(menu)

done = False
while not done:
Expand Down Expand Up @@ -104,6 +109,10 @@ def main():
print("Saved Sites:")
for site in pm.password_dict:
print(site)
elif choice == 'c': #CHECK CONDITION AND CLEAR THE CLI
clear_screen()
print(menu)
print("Cleared the screen.")
elif choice == 'q':
done = True
print("Goodbye!")
Expand All @@ -112,4 +121,4 @@ def main():


if __name__ == '__main__':
main()
main()
3 changes: 3 additions & 0 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def add_password(self, site, password):
if site in self.password_dict:
print(f"Warning: A password for the site '{site}' already exists.")
return
while len(password) < 8: #ENSURES THAT PASSWORD IS ATLEAST 8 CHARACTERS LONG
print("Error: Password must be at least 8 characters long.")
password = input("Please enter a valid password: ").strip()#WILL CONTINUE PROMPTING USER TO ENTER THE PASSWORD IN THE CORRECT FORMAT
self.password_dict[site] = password
if self.password_file is not None:
with open(self.password_file, 'a+') as f:
Expand Down

0 comments on commit ab87640

Please sign in to comment.