-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
125 lines (88 loc) · 3.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
from colorama import *
import os
from os import system
import json
import time
# Start up
system('title Password Manager')
# System
def readPass():
with open('passwords.json', 'r') as file:
content = file.read()
password = json.loads(content)
return password
def writePass(content):
with open('passwords.json', 'w') as f:
json.dump(content, f, indent=4)
# Variables
lightblue = Fore.LIGHTBLUE_EX
red = Fore.RED
green = Fore.GREEN
white = Fore.RESET
password = readPass()
# Code
def set_information():
os.system('cls')
print("What would you like to change?")
new_information = str.lower(input("Choose Platform >>> "))
new_email = input("New Email >>> ")
new_password = input("New Password >>> ")
password["passwords"][f"{new_information}"]["email"] = new_email
password["passwords"][f"{new_information}"]["password"] = new_password
writePass(password)
print(green + f"New Email: {new_email}\nNew Password: {new_password}" + white)
os.system('pause')
main_menu()
def set_information_combo():
os.system('cls')
new_information = str.lower(input("Choose Platform >>> "))
print(f"Please enter the combo formatted like email-password`")
new_combo = input("Combo >>> ")
new_email, new_password = new_combo.split("-")
password["passwords"][f"{new_information}"]["email"] = new_email
password["passwords"][f"{new_information}"]["password"] = new_password
writePass(password)
print(green + f"New Email: {new_email}\nNew Password: {new_password}" + white)
os.system('pause')
main_menu()
def view_information():
os.system('cls')
print("What would you like to see?")
information = str.lower(input("Choose Platform >>> "))
print("Email: " + green + password["passwords"][f"{information}"]["email"] + white)
print("Password: " + green + password["passwords"][f"{information}"]["password"] + white)
os.system('pause')
main_menu()
def main_menu():
os.system('cls')
print("Welcome to Password Manager, what would you like to do?")
print("Current Commands: View, Set, Combo")
option = str.lower(input("Option >>> "))
if option == "view":
view_information()
elif option == "set":
set_information()
elif option == "combo":
set_information_combo()
def auth():
os.system('cls')
if password["system"]["first_startup"] == True:
print("Please set a numerical authorization code.")
new_code = int(input("New Code >>> "))
password["system"]["access_code"] = new_code
password["system"]["first_startup"] = False
writePass(password)
main_menu()
else:
print("Please enter your authorization code.")
code = int(input("Code >>>"))
if code == password["system"]["access_code"]:
print(green + "Access Granted" + white)
time.sleep(1)
main_menu()
elif code != password["system"]["access_code"]:
print(red + "Access Denied" + white)
time.sleep(1)
auth()
# Start Up
auth()