def save(password): today = time.strftime("%m/%d/%Y") conn = sqlite3.connect('savedPasswords.db') c = conn.cursor() ui.clearScreen() name = input("What Name would you like to store this password as?\n\n") ui.clearScreen() username = input( "What Username (if any), would you like to save with this password?\n\n" ) ui.clearScreen() print(ui.Screen['verifySaveScreen']['header']) ui.innerSpace(8) print("Date: " + today) print("Name: " + name) print("Username: "******"Password: "******"CREATE TABLE IF NOT EXISTS passwords (date TEXT, name TEXT, username TEXT, password TEXT)" ) c.execute( "INSERT INTO passwords (date,name,username,password) VALUES (?,?,?,?)", (today, name, username, password)) conn.commit() c.close() conn.close() elif (choice == 2): Database.save(password) else: c.close() conn.close() quit()
def searchDB(name): conn = sqlite3.connect('savedPasswords.db') c = conn.cursor() ui.clearScreen() print(ui.Screen['findPasswordScreen']['header']) ui.innerSpace(2) for row in c.execute("SELECT * FROM passwords WHERE name=?", (name, )): print(row) ui.innerSpace(15) c.close() conn.close() input("Hit any Key to proceed...")
def drawScreen(SCREEN, option=None): ui.clearScreen() print(ui.Screen[SCREEN]['header']) if (option != None): print("New Password: "******"welcomeScreen") elif (choice == 3): drawScreen('findPasswordScreen') else: quit() elif (SCREEN == 'newPasswordScreen'): if (choice == 1): newPassword = gen.GenerateBasic() elif (choice == 2): newPassword = gen.GenerateSpecial() elif (choice == 3): newPassword = gen.GeneratePhrase() else: quit() drawScreen('savePasswordScreen', newPassword) elif (SCREEN == 'savePasswordScreen'): if (choice == 1): db.save(option) elif (choice == 2): newPassword = gen.GenerateBasic() drawScreen('savePasswordScreen', newPassword) elif (choice == 3): newPassword = gen.GenerateSpecial() drawScreen('savePasswordScreen', newPassword) elif (choice == 4): newPassword = gen.GeneratePhrase() drawScreen('savePasswordScreen', newPassword) elif (choice == 5): drawScreen('newPasswordScreen') else: quit() elif (SCREEN == 'findPasswordScreen'): db.searchDB(choice) drawScreen("welcomeScreen")