|
2 | 2 | import random |
3 | 3 | import time |
4 | 4 |
|
5 | | -project_version = '1.0.2' |
| 5 | +project_version = '1.0.3' |
| 6 | +admin_signedin = False |
6 | 7 |
|
7 | 8 | print(f"Welcome to the PasswordManager Application version: " + project_version + |
8 | 9 | f"\nFor more information please go to the github @" |
9 | 10 | f"\nhttps://github.com/Shini9000/PasswordManagerProject" |
10 | 11 | f"\nAnd thank you for downloading and testing my application :)\n\n") |
11 | 12 |
|
| 13 | +""" safe keeping module |
| 14 | +def savepassword(result_string): |
| 15 | + print(result_string) |
| 16 | + if input(f'Do you wish to save this password?').capitalize() == 'Y': |
| 17 | + print(f'Not implemented as of V1.0.3')# |
| 18 | + admin_signedin = not False |
| 19 | + admin_signon(admin_signedin) |
| 20 | + else: |
| 21 | + print(f'Returning to main menu!') |
| 22 | +
|
| 23 | +
|
| 24 | +def admin_signon(admin_signedin): |
| 25 | + print(admin_signedin) |
| 26 | + input('A') |
| 27 | +""" |
| 28 | + |
| 29 | +# Function to generate the password |
| 30 | +def generatepassword(): |
| 31 | + print(f"Generate a new password") |
| 32 | + password_type_select = input(f"\n\nSelect an type: " |
| 33 | + f"\n 1. Uppercase " # ABC |
| 34 | + f"\n 2. Lowercase " # abc |
| 35 | + f"\n 3. Numbers " # 123 |
| 36 | + f"\n 4. Mix " # Ab3 |
| 37 | + f"\n 5. GenericPassword (Cap,Num and Sym" # Yz1! |
| 38 | + f"\nEnter selection: ") |
| 39 | + try: |
| 40 | + selection = int(password_type_select) |
| 41 | + except ValueError: |
| 42 | + print(f"not a digit") |
| 43 | + if selection not in (1, 2, 3, 4, 5): |
| 44 | + print(f'Please select a valid option!') |
| 45 | + generatepassword() |
| 46 | + match selection: |
| 47 | + case 1: |
| 48 | + # Uppercase password generator |
| 49 | + letters = string.ascii_uppercase |
| 50 | + result_string = ''.join( |
| 51 | + (random.choice(letters) for i in range(int(input("Select a password length: "))))) |
| 52 | + result_string.startswith("\n") |
| 53 | + print("\n" + result_string + "\n") |
| 54 | + print(f'Returning to main menu!') |
| 55 | + case 2: |
| 56 | + # Lowercase password generator |
| 57 | + letters = string.ascii_lowercase |
| 58 | + result_string = ''.join( |
| 59 | + (random.choice(letters) for i in range(int(input("Select a password length: "))))) |
| 60 | + result_string.startswith("\n") |
| 61 | + print("\n" + result_string + "\n") |
| 62 | + print(f'Returning to main menu!') |
| 63 | + case 3: |
| 64 | + # Number password generator |
| 65 | + numbers = string.digits |
| 66 | + result_string = ''.join( |
| 67 | + (random.choice(numbers) for i in range(int(input("Select a password length: "))))) |
| 68 | + result_string.startswith("\n") |
| 69 | + print("\n" + result_string + "\n") |
| 70 | + print(f'Returning to main menu!') |
| 71 | + case 4: |
| 72 | + # Mix password generator |
| 73 | + generic_letters = string.ascii_letters |
| 74 | + numbers = string.digits |
| 75 | + string_line = numbers + generic_letters |
| 76 | + result_string = ''.join( |
| 77 | + (random.choice(string_line) for i in range(int(input("Select a password length: "))))) |
| 78 | + result_string.startswith("\n") |
| 79 | + print("\n" + result_string + "\n") |
| 80 | + print(f'Returning to main menu!') |
| 81 | + case 5: |
| 82 | + # Generic password generator |
| 83 | + string_letters = string.ascii_letters |
| 84 | + string_numbers = string.digits |
| 85 | + string_symbols = string.punctuation |
| 86 | + string_line = string_letters + string_symbols + string_numbers |
| 87 | + result_string = ''.join( |
| 88 | + (random.choice(string_line) for i in range(int(input("Select a password length: "))))) |
| 89 | + result_string.startswith("\n") |
| 90 | + print("\n" + result_string + "\n") |
| 91 | + print(f'Returning to main menu!') |
| 92 | + savepassword(result_string) |
| 93 | + |
| 94 | + |
| 95 | +def savepassword(result_string): |
| 96 | + print(result_string) |
| 97 | + if input(f'Do you wish to save this password?').capitalize() == 'Y': |
| 98 | + print(f'Not implemented as of V1.0.3') |
| 99 | + admin_signedin = not False |
| 100 | + admin_signon(admin_signedin) |
| 101 | + else: |
| 102 | + print(f'Returning to main menu!') |
| 103 | + |
| 104 | +def admin_signon(admin_signedin): |
| 105 | + print(admin_signedin) |
| 106 | + input('A') |
| 107 | + |
12 | 108 | # true loop |
13 | 109 | while True: |
14 | | - time.sleep(3.5) |
| 110 | + time.sleep(2.5) |
15 | 111 | # Main menu loop |
16 | 112 | user_input = input(f"Choose an option: " |
17 | 113 | f"\n 1. Generate Password " |
18 | 114 | f"\n 2. View Passwords " |
19 | 115 | f"\n 3. View Accounts " |
20 | 116 | f"\n 4. Add Account " |
21 | 117 | f"\n 5. Delete Account " |
22 | | - f"\n 6. Exit Application " |
| 118 | + f"\n 6. Help menu" # Help menu |
| 119 | + f"\n 7. Exit Application " |
23 | 120 | f"\nEnter Input: ") |
24 | 121 | try: |
25 | 122 | val = int(user_input) |
26 | 123 | except ValueError: |
27 | 124 | print(f"not a digit") |
28 | 125 | # Check if input is valid |
29 | | - if val in (1, 2, 3, 4, 5, 6): |
30 | | - match val: |
31 | | - # Proceed to generate a password |
32 | | - case 1: |
33 | | - print(f"Generate a new password") |
34 | | - password_type_select = input(f"Select an type: " |
35 | | - f"\n1. Uppercase " # ABC |
36 | | - f"\n2. Lowercase " # abc |
37 | | - f"\n3. Numbers " # 123 |
38 | | - f"\n4. Mix " # Ab3 |
39 | | - f"\n5. GenericPassword (Cap,Num and Sym" # Ab3! |
40 | | - f"\n6. Debug(Unsafe size) " # Size of 200000 |
41 | | - f"\n\nEnter selection: ") |
42 | | - try: |
43 | | - selection = int(password_type_select) |
44 | | - except ValueError: |
45 | | - print(f"not a digit") |
46 | | - match selection: |
47 | | - case 1: |
48 | | - letters = string.ascii_uppercase |
49 | | - result_string = ''.join( |
50 | | - (random.choice(letters) for i in range(int(input("Select a password length: "))))) |
51 | | - result_string.startswith("\n") |
52 | | - print("\n" + result_string + "\n") |
53 | | - print(f'Returning to main menu!') |
54 | | - case 2: |
55 | | - letters = string.ascii_lowercase |
56 | | - result_string = ''.join( |
57 | | - (random.choice(letters) for i in range(int(input("Select a password length: "))))) |
58 | | - result_string.startswith("\n") |
59 | | - print("\n" + result_string + "\n") |
60 | | - print(f'Returning to main menu!') |
61 | | - case 3: |
62 | | - numbers = string.digits |
63 | | - result_string = ''.join( |
64 | | - (random.choice(numbers) for i in range(int(input("Select a password length: "))))) |
65 | | - result_string.startswith("\n") |
66 | | - print("\n" + result_string + "\n") |
67 | | - print(f'Returning to main menu!') |
68 | | - case 4: |
69 | | - generic_letters = string.ascii_letters |
70 | | - numbers = string.digits |
71 | | - string_line = numbers + generic_letters |
72 | | - result_string = ''.join( |
73 | | - (random.choice(string_line) for i in range(int(input("Select a password length: "))))) |
74 | | - result_string.startswith("\n") |
75 | | - print("\n" + result_string + "\n") |
76 | | - print(f'Returning to main menu!') |
77 | | - case 5: |
78 | | - string_letters = string.ascii_letters |
79 | | - string_numbers = string.digits |
80 | | - string_symbols = string.punctuation |
81 | | - string_line = string_letters + string_symbols + string_numbers |
82 | | - result_string = ''.join( |
83 | | - (random.choice(string_line) for i in range(int(input("Select a password length: "))))) |
84 | | - result_string.startswith("\n") |
85 | | - print("\n" + result_string + "\n") |
86 | | - print(f'Returning to main menu!') |
87 | | - # Not implemented as of V1.0.1 |
88 | | - case 2: |
89 | | - print(f'Test 2') |
90 | | - case 3: |
91 | | - print(f'Test 3') |
92 | | - case 4: |
93 | | - print(f'Test 4') |
94 | | - case 5: |
95 | | - print(f'Test 5') |
96 | | - # Exit the programme |
97 | | - case 6: |
98 | | - print(f'Test 6') |
99 | | - quit('Quit programme') |
100 | | - else: |
101 | | - print("Enter a valid number") |
| 126 | + if val not in (1, 2, 3, 4, 5, 6, 7): |
| 127 | + print(f'Please select a valid option!') |
| 128 | + continue |
| 129 | + match val: |
| 130 | + # Proceed to generate a password |
| 131 | + case 1: |
| 132 | + generatepassword() |
| 133 | + # Not implemented as of V1.0.1 |
| 134 | + case 2: |
| 135 | + print(f'Password management not available in version: ' + project_version) |
| 136 | + case 3: |
| 137 | + print(f'Account management not available in version: ' + project_version) |
| 138 | + case 4: |
| 139 | + print(f'Test 4') |
| 140 | + case 5: |
| 141 | + print(f'Account management not available in version: ' + project_version) |
| 142 | + case 6: |
| 143 | + print(f'Help menu') |
| 144 | + file = open("help.txt") |
| 145 | + print(file.read()) |
| 146 | + input('Press enter to continue... ') |
| 147 | + file.close() |
| 148 | + print(f'Returning to main menu please wait.') |
| 149 | + continue |
| 150 | + |
| 151 | + # Exit the programme |
| 152 | + case 7: |
| 153 | + print(f'Test 7') |
| 154 | + quit('Quit programme') |
0 commit comments