From 5c8da92abaa54822b18c58e28d82db8fdd4e391b Mon Sep 17 00:00:00 2001 From: "LAPTOP-SNSEHSAR\\ayush" Date: Wed, 24 Mar 2021 02:48:25 +0530 Subject: [PATCH 1/6] GUI implementation complete --- Password-Manager-GUI/passwords.py | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Password-Manager-GUI/passwords.py diff --git a/Password-Manager-GUI/passwords.py b/Password-Manager-GUI/passwords.py new file mode 100644 index 0000000000..d1b3744140 --- /dev/null +++ b/Password-Manager-GUI/passwords.py @@ -0,0 +1,46 @@ +from tkinter import * +import sqlite3 +from tkinter import messagebox + +root = Tk() +root.title("Password Manager") +root.geometry("500x400") +root.minsize(600, 400) +root.maxsize(600, 400) + +frame = Frame(root, bg="#774A9F", bd=5) +frame.place(relx=0.50, rely=0.50, relwidth=0.98, relheight=0.45, anchor = "n") + +#Create Text Boxes +website = Entry(root, width=30) +website.grid(row=1, column=1, padx=20,pady=5) +username = Entry(root, width=30) +username.grid(row=2, column=1, padx=20,pady=5) +password = Entry(root, width=30) +password.grid(row=3, column=1, padx=20,pady=5) + +#Create Text Box Labels +website_label = Label(root, text = "Website:") +website_label.grid(row=1, column=0) +username_label = Label(root, text = " Username:") +username_label.grid(row=2, column=0) +password_label = Label(root, text = "Password:") +password_label.grid(row=3, column=0) + + +#Create Buttons +submit_btn = Button(root, text = "Add Password") +submit_btn.grid(row = 5, column=1, pady=5, padx=15, ipadx=35) +query_btn = Button(root, text = "Show All") +query_btn.grid(row=6, column=1, pady=5, padx=5, ipadx=35) + +#Create a Label to show stored passwords +global query_label +query_label = Label(frame, anchor="nw", justify="left") +query_label.place(relwidth=1, relheight=1) + +def main(): + root.mainloop() + +if __name__ == '__main__': + main() \ No newline at end of file From 556394e3cb824b1c4403dcfc22d2e5ea4a775127 Mon Sep 17 00:00:00 2001 From: "LAPTOP-SNSEHSAR\\ayush" Date: Wed, 24 Mar 2021 03:48:00 +0530 Subject: [PATCH 2/6] Database queries added --- Password-Manager-GUI/passwords.py | 77 +++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/Password-Manager-GUI/passwords.py b/Password-Manager-GUI/passwords.py index d1b3744140..60a20548bc 100644 --- a/Password-Manager-GUI/passwords.py +++ b/Password-Manager-GUI/passwords.py @@ -1,6 +1,77 @@ from tkinter import * -import sqlite3 from tkinter import messagebox +import sqlite3 +from sqlite3 import Error + +# Function to connect to the SQL Database +def sql_connection(): + try: + con = sqlite3.connect('passwordManager.db') + return con + except Error: + print(Error) + +# Function to create table +def sql_table(con): + cursorObj = con.cursor() + cursorObj.execute("CREATE TABLE IF NOT EXISTS passwordStore(website text, username text, pass text,test text)") + con.commit() + +# Call functions to connect to database and create table +con = sql_connection() +sql_table(con) + +#Create submit function for database +def submit(con): + cursor = con.cursor() + #Insert Into Table + if website.get()!="" and username.get()!="" and password.get()!="": + cursor.execute("INSERT INTO passwordStore VALUES (:website, :username, :password)", + { + 'website': website.get(), + 'username': username.get(), + 'password': password.get() + } + ) + con.commit() + # Message box + messagebox.showinfo("Info", "Record Added in Database!") + + # After data entry clear the text boxes + website.delete(0, END) + username.delete(0, END) + password.delete(0, END) + + else: + messagebox.showinfo("Alert", "Please fill all details!") + +# Create Query Function +def query(con): + + #set button text + query_btn.configure(text="Hide Records", command=hide) + + cursor = con.cursor() + + #Query the database + cursor.execute("SELECT *, oid FROM passwordStore") + records = cursor.fetchall() + #print(records) + + p_records = " Id \t\t Website \t\t Username \t\t Password\n" + for record in records: + p_records += str(record[3])+ "\t\t" +str(record[0])+ "\t\t" + str(record[1])+ "\t\t" + str(record[2]) + "\n" + #print(record) + + query_label['text'] = p_records + # Commit changes + con.commit() + +#Create Function to Hide Records +def hide(): + query_label['text'] = "" + query_btn.configure(text="Show Records", command=lambda:query(con)) + root = Tk() root.title("Password Manager") @@ -29,9 +100,9 @@ #Create Buttons -submit_btn = Button(root, text = "Add Password") +submit_btn = Button(root, text = "Add Password",command = lambda: submit(con)) submit_btn.grid(row = 5, column=1, pady=5, padx=15, ipadx=35) -query_btn = Button(root, text = "Show All") +query_btn = Button(root, text = "Show All",command = lambda: query(con)) query_btn.grid(row=6, column=1, pady=5, padx=5, ipadx=35) #Create a Label to show stored passwords From 809870e5225e502f14487a9e12621d6b332895e6 Mon Sep 17 00:00:00 2001 From: "LAPTOP-SNSEHSAR\\ayush" Date: Wed, 24 Mar 2021 03:59:38 +0530 Subject: [PATCH 3/6] remove test column from table --- Password-Manager-GUI/passwords.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Password-Manager-GUI/passwords.py b/Password-Manager-GUI/passwords.py index 60a20548bc..fab0b86fc0 100644 --- a/Password-Manager-GUI/passwords.py +++ b/Password-Manager-GUI/passwords.py @@ -14,7 +14,7 @@ def sql_connection(): # Function to create table def sql_table(con): cursorObj = con.cursor() - cursorObj.execute("CREATE TABLE IF NOT EXISTS passwordStore(website text, username text, pass text,test text)") + cursorObj.execute("CREATE TABLE IF NOT EXISTS passwords(website text, username text, pass text)") con.commit() # Call functions to connect to database and create table @@ -26,7 +26,7 @@ def submit(con): cursor = con.cursor() #Insert Into Table if website.get()!="" and username.get()!="" and password.get()!="": - cursor.execute("INSERT INTO passwordStore VALUES (:website, :username, :password)", + cursor.execute("INSERT INTO passwords VALUES (:website, :username, :password)", { 'website': website.get(), 'username': username.get(), @@ -54,7 +54,7 @@ def query(con): cursor = con.cursor() #Query the database - cursor.execute("SELECT *, oid FROM passwordStore") + cursor.execute("SELECT *, oid FROM passwords") records = cursor.fetchall() #print(records) From 3c309b33a26d2a3a961bb3f87bae17d89cf12ce3 Mon Sep 17 00:00:00 2001 From: "LAPTOP-SNSEHSAR\\ayush" Date: Wed, 24 Mar 2021 04:02:51 +0530 Subject: [PATCH 4/6] Readme added --- Password-Manager-GUI/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Password-Manager-GUI/README.md diff --git a/Password-Manager-GUI/README.md b/Password-Manager-GUI/README.md new file mode 100644 index 0000000000..94387a5b45 --- /dev/null +++ b/Password-Manager-GUI/README.md @@ -0,0 +1,21 @@ +# Password Manager +This script opens up a Password Manager GUI on execution. It allows the user to store all their passwords in a local SQL database + +## Setup instructions +In order to run this script, you need to have Python and pip installed on your system. +After you're done installing Python and pip, Open the terminal in the project folder and run +``` +python passwords.py +``` +or +``` +python3 passwords.py +``` +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. + +## Output +![Sample output of Password Manager GUI](https://i.postimg.cc/3RThcWfQ/password-Manager.png) +![Sample output of Passwords displayed from Database](https://i.postimg.cc/L4vSx9zG/display-Pass.png) + +## Author +[Ayush Jain](https://github.com/Ayushjain2205) \ No newline at end of file From 7c1fb643a5ee5382050f2f965a4288c090a59c15 Mon Sep 17 00:00:00 2001 From: "LAPTOP-SNSEHSAR\\ayush" Date: Wed, 31 Mar 2021 05:59:17 +0530 Subject: [PATCH 5/6] Master password functionality added --- Password-Manager-GUI/passwords.py | 107 +++++++++++++++++------------- 1 file changed, 60 insertions(+), 47 deletions(-) diff --git a/Password-Manager-GUI/passwords.py b/Password-Manager-GUI/passwords.py index fab0b86fc0..527e065695 100644 --- a/Password-Manager-GUI/passwords.py +++ b/Password-Manager-GUI/passwords.py @@ -1,7 +1,11 @@ from tkinter import * -from tkinter import messagebox +from tkinter import messagebox,simpledialog import sqlite3 from sqlite3 import Error +import sys + +# Store Master password +master_password = sys.argv[1] # Function to connect to the SQL Database def sql_connection(): @@ -11,28 +15,29 @@ def sql_connection(): except Error: print(Error) -# Function to create table +# Function to create table def sql_table(con): cursorObj = con.cursor() - cursorObj.execute("CREATE TABLE IF NOT EXISTS passwords(website text, username text, pass text)") + cursorObj.execute( + "CREATE TABLE IF NOT EXISTS passwords(website text, username text, pass text)") con.commit() # Call functions to connect to database and create table con = sql_connection() sql_table(con) -#Create submit function for database +# Create submit function for database def submit(con): cursor = con.cursor() - #Insert Into Table - if website.get()!="" and username.get()!="" and password.get()!="": + # Insert Into Table + if website.get() != "" and username.get() != "" and password.get() != "": cursor.execute("INSERT INTO passwords VALUES (:website, :username, :password)", - { - 'website': website.get(), - 'username': username.get(), - 'password': password.get() - } - ) + { + 'website': website.get(), + 'username': username.get(), + 'password': password.get() + } + ) con.commit() # Message box messagebox.showinfo("Info", "Record Added in Database!") @@ -48,29 +53,36 @@ def submit(con): # Create Query Function def query(con): - #set button text - query_btn.configure(text="Hide Records", command=hide) - - cursor = con.cursor() - - #Query the database - cursor.execute("SELECT *, oid FROM passwords") - records = cursor.fetchall() - #print(records) - - p_records = " Id \t\t Website \t\t Username \t\t Password\n" - for record in records: - p_records += str(record[3])+ "\t\t" +str(record[0])+ "\t\t" + str(record[1])+ "\t\t" + str(record[2]) + "\n" - #print(record) - - query_label['text'] = p_records - # Commit changes - con.commit() + password = simpledialog.askstring("Password","Enter Master Password") + if(password == master_password): + # set button text + query_btn.configure(text="Hide Records", command=hide) + cursor = con.cursor() + # Query the database + cursor.execute("SELECT *, oid FROM passwords") + records = cursor.fetchall() + + p_records = 'ID'.ljust(10)+ 'Website'.ljust(40)+'Username'.ljust(70)+'Password'.ljust(100)+'\n' + + for record in records: + single_record = "" + single_record += (str(record[3]).ljust(10) + + str(record[0]).ljust(40)+str(record[1]).ljust(70)+str(record[2]).ljust(100)) + single_record += '\n' + # print(single_record) + p_records += single_record + query_label['text'] = p_records + # Commit changes + con.commit() + p_records = "" + + else: + messagebox.showinfo("Failed!", "Authentication failed!") -#Create Function to Hide Records +# Create Function to Hide Records def hide(): query_label['text'] = "" - query_btn.configure(text="Show Records", command=lambda:query(con)) + query_btn.configure(text="Show Records", command=lambda: query(con)) root = Tk() @@ -80,32 +92,32 @@ def hide(): root.maxsize(600, 400) frame = Frame(root, bg="#774A9F", bd=5) -frame.place(relx=0.50, rely=0.50, relwidth=0.98, relheight=0.45, anchor = "n") +frame.place(relx=0.50, rely=0.50, relwidth=0.98, relheight=0.45, anchor="n") -#Create Text Boxes +# Create Text Boxes website = Entry(root, width=30) -website.grid(row=1, column=1, padx=20,pady=5) +website.grid(row=1, column=1, padx=20, pady=5) username = Entry(root, width=30) -username.grid(row=2, column=1, padx=20,pady=5) +username.grid(row=2, column=1, padx=20, pady=5) password = Entry(root, width=30) -password.grid(row=3, column=1, padx=20,pady=5) +password.grid(row=3, column=1, padx=20, pady=5) -#Create Text Box Labels -website_label = Label(root, text = "Website:") +# Create Text Box Labels +website_label = Label(root, text="Website:") website_label.grid(row=1, column=0) -username_label = Label(root, text = " Username:") +username_label = Label(root, text=" Username:") username_label.grid(row=2, column=0) -password_label = Label(root, text = "Password:") +password_label = Label(root, text="Password:") password_label.grid(row=3, column=0) -#Create Buttons -submit_btn = Button(root, text = "Add Password",command = lambda: submit(con)) -submit_btn.grid(row = 5, column=1, pady=5, padx=15, ipadx=35) -query_btn = Button(root, text = "Show All",command = lambda: query(con)) +# Create Buttons +submit_btn = Button(root, text="Add Password", command=lambda: submit(con)) +submit_btn.grid(row=5, column=1, pady=5, padx=15, ipadx=35) +query_btn = Button(root, text="Show All", command=lambda: query(con)) query_btn.grid(row=6, column=1, pady=5, padx=5, ipadx=35) -#Create a Label to show stored passwords +# Create a Label to show stored passwords global query_label query_label = Label(frame, anchor="nw", justify="left") query_label.place(relwidth=1, relheight=1) @@ -113,5 +125,6 @@ def hide(): def main(): root.mainloop() + if __name__ == '__main__': - main() \ No newline at end of file + main() From 233eaa6c341b67ff60089a9584ca92ab34b4ece7 Mon Sep 17 00:00:00 2001 From: "LAPTOP-SNSEHSAR\\ayush" Date: Wed, 31 Mar 2021 06:00:37 +0530 Subject: [PATCH 6/6] Command line arguments added --- Password-Manager-GUI/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Password-Manager-GUI/README.md b/Password-Manager-GUI/README.md index 94387a5b45..e93c4648f3 100644 --- a/Password-Manager-GUI/README.md +++ b/Password-Manager-GUI/README.md @@ -5,11 +5,11 @@ This script opens up a Password Manager GUI on execution. It allows the user to In order to run this script, you need to have Python and pip installed on your system. After you're done installing Python and pip, Open the terminal in the project folder and run ``` -python passwords.py +python passwords.py ``` or ``` -python3 passwords.py +python3 passwords.py ``` 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.