Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec7c886

Browse files
Merge pull request avinashkranjan#721 from Ayushjain2205/password-manager-GUI
Password manager GUI
2 parents d7288b5 + 233eaa6 commit ec7c886

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

‎Password-Manager-GUI/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Password Manager
2+
This script opens up a Password Manager GUI on execution. It allows the user to store all their passwords in a local SQL database
3+
4+
## Setup instructions
5+
In order to run this script, you need to have Python and pip installed on your system.
6+
After you're done installing Python and pip, Open the terminal in the project folder and run
7+
```
8+
python passwords.py <Master password>
9+
```
10+
or
11+
```
12+
python3 passwords.py <Master password>
13+
```
14+
depending upon the python version. Make sure that you are running the command from the same virtual environment in which the required modules are installed.
15+
16+
## Output
17+
![Sample output of Password Manager GUI](https://i.postimg.cc/3RThcWfQ/password-Manager.png)
18+
![Sample output of Passwords displayed from Database](https://i.postimg.cc/L4vSx9zG/display-Pass.png)
19+
20+
## Author
21+
[Ayush Jain](https://github.com/Ayushjain2205)

‎Password-Manager-GUI/passwords.py‎

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
from tkinter import *
2+
from tkinter import messagebox,simpledialog
3+
import sqlite3
4+
from sqlite3 import Error
5+
import sys
6+
7+
# Store Master password
8+
master_password = sys.argv[1]
9+
10+
# Function to connect to the SQL Database
11+
def sql_connection():
12+
try:
13+
con = sqlite3.connect('passwordManager.db')
14+
return con
15+
except Error:
16+
print(Error)
17+
18+
# Function to create table
19+
def sql_table(con):
20+
cursorObj = con.cursor()
21+
cursorObj.execute(
22+
"CREATE TABLE IF NOT EXISTS passwords(website text, username text, pass text)")
23+
con.commit()
24+
25+
# Call functions to connect to database and create table
26+
con = sql_connection()
27+
sql_table(con)
28+
29+
# Create submit function for database
30+
def submit(con):
31+
cursor = con.cursor()
32+
# Insert Into Table
33+
if website.get() != "" and username.get() != "" and password.get() != "":
34+
cursor.execute("INSERT INTO passwords VALUES (:website, :username, :password)",
35+
{
36+
'website': website.get(),
37+
'username': username.get(),
38+
'password': password.get()
39+
}
40+
)
41+
con.commit()
42+
# Message box
43+
messagebox.showinfo("Info", "Record Added in Database!")
44+
45+
# After data entry clear the text boxes
46+
website.delete(0, END)
47+
username.delete(0, END)
48+
password.delete(0, END)
49+
50+
else:
51+
messagebox.showinfo("Alert", "Please fill all details!")
52+
53+
# Create Query Function
54+
def query(con):
55+
56+
password = simpledialog.askstring("Password","Enter Master Password")
57+
if(password == master_password):
58+
# set button text
59+
query_btn.configure(text="Hide Records", command=hide)
60+
cursor = con.cursor()
61+
# Query the database
62+
cursor.execute("SELECT *, oid FROM passwords")
63+
records = cursor.fetchall()
64+
65+
p_records = 'ID'.ljust(10)+ 'Website'.ljust(40)+'Username'.ljust(70)+'Password'.ljust(100)+'\n'
66+
67+
for record in records:
68+
single_record = ""
69+
single_record += (str(record[3]).ljust(10) +
70+
str(record[0]).ljust(40)+str(record[1]).ljust(70)+str(record[2]).ljust(100))
71+
single_record += '\n'
72+
# print(single_record)
73+
p_records += single_record
74+
query_label['text'] = p_records
75+
# Commit changes
76+
con.commit()
77+
p_records = ""
78+
79+
else:
80+
messagebox.showinfo("Failed!", "Authentication failed!")
81+
82+
# Create Function to Hide Records
83+
def hide():
84+
query_label['text'] = ""
85+
query_btn.configure(text="Show Records", command=lambda: query(con))
86+
87+
88+
root = Tk()
89+
root.title("Password Manager")
90+
root.geometry("500x400")
91+
root.minsize(600, 400)
92+
root.maxsize(600, 400)
93+
94+
frame = Frame(root, bg="#774A9F", bd=5)
95+
frame.place(relx=0.50, rely=0.50, relwidth=0.98, relheight=0.45, anchor="n")
96+
97+
# Create Text Boxes
98+
website = Entry(root, width=30)
99+
website.grid(row=1, column=1, padx=20, pady=5)
100+
username = Entry(root, width=30)
101+
username.grid(row=2, column=1, padx=20, pady=5)
102+
password = Entry(root, width=30)
103+
password.grid(row=3, column=1, padx=20, pady=5)
104+
105+
# Create Text Box Labels
106+
website_label = Label(root, text="Website:")
107+
website_label.grid(row=1, column=0)
108+
username_label = Label(root, text=" Username:")
109+
username_label.grid(row=2, column=0)
110+
password_label = Label(root, text="Password:")
111+
password_label.grid(row=3, column=0)
112+
113+
114+
# Create Buttons
115+
submit_btn = Button(root, text="Add Password", command=lambda: submit(con))
116+
submit_btn.grid(row=5, column=1, pady=5, padx=15, ipadx=35)
117+
query_btn = Button(root, text="Show All", command=lambda: query(con))
118+
query_btn.grid(row=6, column=1, pady=5, padx=5, ipadx=35)
119+
120+
# Create a Label to show stored passwords
121+
global query_label
122+
query_label = Label(frame, anchor="nw", justify="left")
123+
query_label.place(relwidth=1, relheight=1)
124+
125+
def main():
126+
root.mainloop()
127+
128+
129+
if __name__ == '__main__':
130+
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /