-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.py
115 lines (90 loc) · 3.34 KB
/
project.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
import tkinter as tk
import random as r
##### SIGN UP PAGE #####
# Create the Sign-Up window
sign = tk.Tk()
sign.geometry("500x500")
sign.title("Sign UP")
# Title Label
label2 = tk.Label(sign, text="SIGN UP", font=('Bold', 30))
label2.pack(padx=50, pady=30)
# Function to get the values and save them in a text file
def get_values():
name = text1.get()
username = text2.get()
password = text3.get()
file = open("info.txt", "a")
file.write(" Username: " + username + " Password: " + password + "\n")
file.close()
# Function to generate a random password
def generatepassword():
all_values = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-',
'_', '=', '+', '[', ']', '{', '}', '|', ';', ':', '"',
',', '.', '/', '<', '>', '?', ' '
]
random_password = ""
for i in range(12):
random_password += r.choice(all_values)
print("Random password")
text3.insert(0, random_password)
# Labels and Entry fields for user input
name = tk.Label(sign, text="Enter your Name", font=('Bold', 15))
name.pack(padx=0, pady=10)
text1 = tk.Entry(sign)
text1.pack()
enter_username = tk.Label(sign, text="Enter your username", font=('Bold', 15))
enter_username.pack(padx=0, pady=10)
text2 = tk.Entry(sign)
text2.pack()
enter_password = tk.Label(sign, text="Enter your password", font=('Bold', 15))
enter_password.pack(padx=0, pady=10)
text3 = tk.Entry(sign)
text3.pack()
# Buttons for generating password and signing up
gbutton = tk.Button(sign, text="Generate Password", font=('Arial', 15), command=generatepassword)
gbutton.pack(padx=2, pady=10)
button = tk.Button(sign, text="Sign UP", font=("Bold", 14), command=get_values)
button.pack(pady=40)
# Run the Sign-Up window
sign.mainloop()
##### LOGIN PAGE #####
# Create the Login window
first = tk.Tk()
first.geometry("500x500")
first.title("Login")
# Title Label
label = tk.Label(first, text="LOGIN", font=('Bold', 30))
label.pack(padx=50, pady=40)
# Labels and Entry fields for username and password
username = tk.Label(first, text="USERNAME", font=('Bold', 19))
username.pack(padx=25, pady=40)
get_user = tk.Entry(first, text="USERNAME")
get_user.pack()
password = tk.Label(first, text="PASSWORD", font=('Bold', 19))
password.pack(padx=25, pady=40)
get_password = tk.Entry(first, text="PASSWORD")
get_password.pack()
# Function to handle login
def login():
username = get_user.get()
password = get_password.get()
file = open("info.txt", "r")
for i in file:
if i != " Username: " + username + " Password: " + password + "\n":
pass
elif i == " Username: " + username + " Password: " + password + "\n":
print("logged in Successfully")
break
else:
print("NOT Logged In")
# Button for login
button = tk.Button(first, text="Log in", font=('Bold', 15), command=login)
button.pack(pady=20)
# Run the Login window
first.mainloop()