From a9c387c54ca51a1c42907e144510099bf84c522b Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Mon, 29 Apr 2019 14:48:54 -0400 Subject: [PATCH 01/11] Create main.py --- main.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/main.py @@ -0,0 +1 @@ + From 31bea571b3c81d46b8b6f43791e97d2f2ea08c1d Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Wed, 1 May 2019 13:27:34 -0400 Subject: [PATCH 02/11] Update main.py --- main.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/main.py b/main.py index 8b137891..9bf16b06 100644 --- a/main.py +++ b/main.py @@ -1 +1,83 @@ +#Defining variables for encrypt/decrypt +associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,:;'\"/\\<>(){}[]-=_+?!" +str1 = "" +str2 = "" +key = "12hjfk3929fjsk3ewe04kwdfje34iew" +sitedata = [] + + +# Function for encrypting a string +def encrypt(message): + global associations + global str1 + global key + n = 0 + while len(key) < len(message): + key += key + associations += associations + l = len(message) + while n < l: + numrepm = associations.find(message[n]) + numrepk = associations.find(key[n]) + finalnum = numrepm + numrepk + letrep = associations[finalnum] + str1 = str1 + letrep + n = n + 1 + return(str1) + +# Function for decrypting a string +def decrypt(message): + global associations + global str2 + global key + n = 0 + while len(key) < len(message): + key += key + associations += associations + l = len(message) + while n < l: + numrepm1 = associations.find(message[n]) + numrepk1 = associations.find(key[n]) + finalnum1 = numrepm1 - numrepk1 + letrep1 = associations[finalnum1] + str2 = str2 + letrep1 + n = n + 1 + return(str2) + + +command = input("Welcome! Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") +running = true +while running == true: + + if command == "r": + pass + elif command == "s": + data = [] + site = input("Please enter the name of the site you wish to store: ") + password = input("Please enter the password belonging to the site: ") + site = encrypt(site) + password = encrypt(password) + data.append(site) + data.append(password) + sitedata.append(data) + key = sitedata.index(data) + print ("Your site key is: {0}. Please write this down and store it in a safe place so you can access it later.".format(key)) + + + elif command == "g": + data = [] + key = input("Please enter the key of the site you wish to retrieve: ") + try: + key = int(key) + except TypeError: + print("Sorry, key not recognized, please try again.") + + elif command == "q": + running = false + else: + print("Sorry, command not understood. Please try again.") + + + + From 6e0d1e15ec167f581000032dbe7278085c46a245 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Wed, 1 May 2019 14:05:11 -0400 Subject: [PATCH 03/11] Update main.py --- main.py | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/main.py b/main.py index 9bf16b06..086dba78 100644 --- a/main.py +++ b/main.py @@ -1,17 +1,18 @@ -#Defining variables for encrypt/decrypt +#Defining variables associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,:;'\"/\\<>(){}[]-=_+?!" str1 = "" -str2 = "" key = "12hjfk3929fjsk3ewe04kwdfje34iew" sitedata = [] +running = 0 + # Function for encrypting a string def encrypt(message): global associations - global str1 global key + str1 = "" n = 0 while len(key) < len(message): key += key @@ -29,8 +30,8 @@ def encrypt(message): # Function for decrypting a string def decrypt(message): global associations - global str2 global key + str2 = "" n = 0 while len(key) < len(message): key += key @@ -47,8 +48,7 @@ def decrypt(message): command = input("Welcome! Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") -running = true -while running == true: +while running == 0: if command == "r": pass @@ -61,23 +61,30 @@ def decrypt(message): data.append(site) data.append(password) sitedata.append(data) - key = sitedata.index(data) - print ("Your site key is: {0}. Please write this down and store it in a safe place so you can access it later.".format(key)) - + code = sitedata.index(data) + print ("Your site code is: {0}. Please write this down and store it in a safe place so you can access it later.".format(code)) + command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") + elif command == "g": - data = [] - key = input("Please enter the key of the site you wish to retrieve: ") + code = input("Please enter the code of the site you wish to retrieve: ") try: - key = int(key) - except TypeError: - print("Sorry, key not recognized, please try again.") + code = int(code) + except ValueError: + print("Sorry, code not recognized, please try again.") + code = int(code) + + data = sitedata[code] + site = data[0] + password = data[1] + site = decrypt(site) + password = decrypt(password) + print("Your password for {0} is {1}.".format(site, password)) + command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") + elif command == "q": - running = false + running = 1 else: print("Sorry, command not understood. Please try again.") - - - - + command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") From 2b820b01ffda144dd30ad24eb91030dbba2adde4 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Fri, 3 May 2019 14:45:55 -0400 Subject: [PATCH 04/11] Update main.py --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 086dba78..b4bab42e 100644 --- a/main.py +++ b/main.py @@ -51,7 +51,7 @@ def decrypt(message): while running == 0: if command == "r": - pass + command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") elif command == "s": data = [] site = input("Please enter the name of the site you wish to store: ") From cf03a1fc2bea2ad9fcf55610c054fe1da5b72fc5 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Thu, 23 May 2019 14:34:39 -0400 Subject: [PATCH 05/11] Update main.py --- main.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index b4bab42e..5efcd1b3 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,24 @@ +import string +import random + + #Defining variables -associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,:;'\"/\\<>(){}[]-=_+?!" +associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,:;'\"/\\<>(){}[]-=_+?!" str1 = "" -key = "12hjfk3929fjsk3ewe04kwdfje34iew" + +keylen = "" +keylen += str(random.randint(1, 9)) +keylen += str(random.randint(0, 9)) +keylen = int(keylen) + +key = "" +counter = 1 +while counter2 <= keylen: + key.join(random.choice(associations)) + counter += 1 + + sitedata = [] running = 0 @@ -46,11 +62,33 @@ def decrypt(message): n = n + 1 return(str2) +# Function for converting an entered string to a list +def resumelist(code): + global sitedata + code1 = code.split() + lencode = len(code1) + halflencode = lencode/2 + x = 0 + while x <= halflencode: + site = code1[0] + password = code1[1] + data = [] + data.append(site) + data.append(password) + sitedata.append(data) + del code1[0] + del code1 + halflencode -= 1 + x += 1 + + return(sitedata) command = input("Welcome! Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") while running == 0: if command == "r": + resumecodeentered = input("Please enter your resume code: ") + sitedata = resumelist(resumecodeentered) command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") elif command == "s": data = [] @@ -84,6 +122,14 @@ def decrypt(message): elif command == "q": + printstring = "" + for p in sitedata: + printstring = printstring + p[0] + printstring = printstring + " " + printstring = printstring + p[1] + printstring = printstring + " " + print("Your resume code is {0}. Please write it down and keep it in a safe place so you can access your data later.".format(printstring)) + print("Your ket is {0}. Please write it down and keep it in a safe place so you can access your data later.".format(key)) running = 1 else: print("Sorry, command not understood. Please try again.") From 93886fe40aa3063f46e24f4a077023ee87d28d63 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Thu, 23 May 2019 14:44:49 -0400 Subject: [PATCH 06/11] Update main.py --- main.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 5efcd1b3..8f55f494 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,6 @@ import string import random - - #Defining variables associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,:;'\"/\\<>(){}[]-=_+?!" str1 = "" @@ -13,9 +11,10 @@ keylen = int(keylen) key = "" +key1 = "" counter = 1 -while counter2 <= keylen: - key.join(random.choice(associations)) +while counter <= keylen: + key += key1.join(random.choice(associations)) counter += 1 From e52023a2ed8e2ce374b3aec4a2004e4bbd80eb89 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Wed, 29 May 2019 09:24:51 -0400 Subject: [PATCH 07/11] Update main.py --- main.py | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 181 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 8f55f494..0212ef7b 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import string import random +from browser.local_storage import storage #Defining variables associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,:;'\"/\\<>(){}[]-=_+?!" @@ -76,20 +77,20 @@ def resumelist(code): data.append(password) sitedata.append(data) del code1[0] - del code1 + del code1[0] halflencode -= 1 x += 1 return(sitedata) -command = input("Welcome! Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") +command = input("Welcome! Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") +resumecodeentered = storage['pstr'] +sitedata = resumelist(resumecodeentered) +key = storage['key'] while running == 0: - if command == "r": - resumecodeentered = input("Please enter your resume code: ") - sitedata = resumelist(resumecodeentered) - command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") - elif command == "s": + + if command == "s": data = [] site = input("Please enter the name of the site you wish to store: ") password = input("Please enter the password belonging to the site: ") @@ -100,7 +101,7 @@ def resumelist(code): sitedata.append(data) code = sitedata.index(data) print ("Your site code is: {0}. Please write this down and store it in a safe place so you can access it later.".format(code)) - command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") elif command == "g": @@ -117,8 +118,175 @@ def resumelist(code): site = decrypt(site) password = decrypt(password) print("Your password for {0} is {1}.".format(site, password)) - command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + + elif command == "c": + + runcheck = 0 + + while runcheck == 0: + import string +import random +from browser.local_storage import storage + +#Defining variables +associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,:;'\"/\\<>(){}[]-=_+?!" +str1 = "" + +keylen = "" +keylen += str(random.randint(1, 9)) +keylen += str(random.randint(0, 9)) +keylen = int(keylen) + +key = "" +key1 = "" +counter = 1 +while counter <= keylen: + key += key1.join(random.choice(associations)) + counter += 1 + + +sitedata = [] +running = 0 + + + +# Function for encrypting a string +def encrypt(message): + global associations + global key + str1 = "" + n = 0 + while len(key) < len(message): + key += key + associations += associations + l = len(message) + while n < l: + numrepm = associations.find(message[n]) + numrepk = associations.find(key[n]) + finalnum = numrepm + numrepk + letrep = associations[finalnum] + str1 = str1 + letrep + n = n + 1 + return(str1) + +# Function for decrypting a string +def decrypt(message): + global associations + global key + str2 = "" + n = 0 + while len(key) < len(message): + key += key + associations += associations + l = len(message) + while n < l: + numrepm1 = associations.find(message[n]) + numrepk1 = associations.find(key[n]) + finalnum1 = numrepm1 - numrepk1 + letrep1 = associations[finalnum1] + str2 = str2 + letrep1 + n = n + 1 + return(str2) + +# Function for converting an entered string to a list +def resumelist(code): + global sitedata + code1 = code.split() + lencode = len(code1) + halflencode = lencode/2 + x = 0 + while x <= halflencode: + site = code1[0] + password = code1[1] + data = [] + data.append(site) + data.append(password) + sitedata.append(data) + del code1[0] + del code1[0] + halflencode -= 1 + x += 1 + + return(sitedata) + +command = input("Welcome! Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") +resumecodeentered = storage['pstr'] +sitedata = resumelist(resumecodeentered) +key = storage['key'] +while running == 0: + + + if command == "s": + data = [] + site = input("Please enter the name of the site you wish to store: ") + password = input("Please enter the password belonging to the site: ") + site = encrypt(site) + password = encrypt(password) + data.append(site) + data.append(password) + sitedata.append(data) + code = sitedata.index(data) + print ("Your site code is: {0}. Please write this down and store it in a safe place so you can access it later.".format(code)) + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") + + + elif command == "g": + code = input("Please enter the code of the site you wish to retrieve: ") + try: + code = int(code) + except ValueError: + print("Sorry, code not recognized, please try again.") + code = int(code) + + data = sitedata[code] + site = data[0] + password = data[1] + site = decrypt(site) + password = decrypt(password) + print("Your password for {0} is {1}.".format(site, password)) + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + + elif command == "c": + + runcheck = 0 + + while runcheck == 0: + confirm = input("Are you sure you want to clear local data? Y or N.") + if confirm == "Y": + del storage['key'] + del storage['pstr'] + runcheck = 1 + elif confirm == "N": + command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck = 1 + else: + print("Sorry, command not recognized, please try again.") + + elif command == "q": + printstring = "" + for p in sitedata: + printstring = printstring + p[0] + printstring = printstring + " " + printstring = printstring + p[1] + printstring = printstring + " " + storage['pstr'] = printstring + storage['key'] = key + print("Goodbye!") + running = 1 + else: + print("Sorry, command not understood. Please try again.") + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + if confirm == "Y": + del storage['key'] + del storage['pstr'] + runcheck = 1 + elif confirm == "N": + command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck = 1 + else: + print("Sorry, command not recognized, please try again.") elif command == "q": printstring = "" @@ -127,9 +295,10 @@ def resumelist(code): printstring = printstring + " " printstring = printstring + p[1] printstring = printstring + " " - print("Your resume code is {0}. Please write it down and keep it in a safe place so you can access your data later.".format(printstring)) - print("Your ket is {0}. Please write it down and keep it in a safe place so you can access your data later.".format(key)) + storage['pstr'] = printstring + storage['key'] = key + print("Goodbye!") running = 1 else: print("Sorry, command not understood. Please try again.") - command = input("Press r to resume a session, press s to store a site and password, press g to retrieve a site and password or press q to print and exit: ") + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") From 61248d9ff78d1d35dcb3eb862e4d7060e5eff5d1 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Wed, 29 May 2019 13:36:00 -0400 Subject: [PATCH 08/11] Update main.py --- main.py | 158 +++----------------------------------------------------- 1 file changed, 7 insertions(+), 151 deletions(-) diff --git a/main.py b/main.py index 0212ef7b..d9884422 100644 --- a/main.py +++ b/main.py @@ -84,136 +84,14 @@ def resumelist(code): return(sitedata) command = input("Welcome! Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") -resumecodeentered = storage['pstr'] -sitedata = resumelist(resumecodeentered) -key = storage['key'] -while running == 0: - - - if command == "s": - data = [] - site = input("Please enter the name of the site you wish to store: ") - password = input("Please enter the password belonging to the site: ") - site = encrypt(site) - password = encrypt(password) - data.append(site) - data.append(password) - sitedata.append(data) - code = sitedata.index(data) - print ("Your site code is: {0}. Please write this down and store it in a safe place so you can access it later.".format(code)) - command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") - - - elif command == "g": - code = input("Please enter the code of the site you wish to retrieve: ") - try: - code = int(code) - except ValueError: - print("Sorry, code not recognized, please try again.") - code = int(code) - - data = sitedata[code] - site = data[0] - password = data[1] - site = decrypt(site) - password = decrypt(password) - print("Your password for {0} is {1}.".format(site, password)) - command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - - elif command == "c": - - runcheck = 0 - - while runcheck == 0: - import string -import random -from browser.local_storage import storage - -#Defining variables -associations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,:;'\"/\\<>(){}[]-=_+?!" -str1 = "" - -keylen = "" -keylen += str(random.randint(1, 9)) -keylen += str(random.randint(0, 9)) -keylen = int(keylen) - -key = "" -key1 = "" -counter = 1 -while counter <= keylen: - key += key1.join(random.choice(associations)) - counter += 1 - -sitedata = [] -running = 0 - - - -# Function for encrypting a string -def encrypt(message): - global associations - global key - str1 = "" - n = 0 - while len(key) < len(message): - key += key - associations += associations - l = len(message) - while n < l: - numrepm = associations.find(message[n]) - numrepk = associations.find(key[n]) - finalnum = numrepm + numrepk - letrep = associations[finalnum] - str1 = str1 + letrep - n = n + 1 - return(str1) - -# Function for decrypting a string -def decrypt(message): - global associations - global key - str2 = "" - n = 0 - while len(key) < len(message): - key += key - associations += associations - l = len(message) - while n < l: - numrepm1 = associations.find(message[n]) - numrepk1 = associations.find(key[n]) - finalnum1 = numrepm1 - numrepk1 - letrep1 = associations[finalnum1] - str2 = str2 + letrep1 - n = n + 1 - return(str2) +try: + resumecodeentered = storage['pstr'] + sitedata = resumelist(resumecodeentered) + key = storage['key'] -# Function for converting an entered string to a list -def resumelist(code): - global sitedata - code1 = code.split() - lencode = len(code1) - halflencode = lencode/2 - x = 0 - while x <= halflencode: - site = code1[0] - password = code1[1] - data = [] - data.append(site) - data.append(password) - sitedata.append(data) - del code1[0] - del code1[0] - halflencode -= 1 - x += 1 - - return(sitedata) +except KeyError: -command = input("Welcome! Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") -resumecodeentered = storage['pstr'] -sitedata = resumelist(resumecodeentered) -key = storage['key'] while running == 0: @@ -252,7 +130,9 @@ def resumelist(code): runcheck = 0 while runcheck == 0: + confirm = input("Are you sure you want to clear local data? Y or N.") + if confirm == "Y": del storage['key'] del storage['pstr'] @@ -274,31 +154,7 @@ def resumelist(code): storage['key'] = key print("Goodbye!") running = 1 - else: - print("Sorry, command not understood. Please try again.") - command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - if confirm == "Y": - del storage['key'] - del storage['pstr'] - runcheck = 1 - elif confirm == "N": - command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - runcheck = 1 - else: - print("Sorry, command not recognized, please try again.") - - elif command == "q": - printstring = "" - for p in sitedata: - printstring = printstring + p[0] - printstring = printstring + " " - printstring = printstring + p[1] - printstring = printstring + " " - storage['pstr'] = printstring - storage['key'] = key - print("Goodbye!") - running = 1 else: print("Sorry, command not understood. Please try again.") command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") From 13714b856a24f352a9e8091a4da0de64ade0162a Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Thu, 30 May 2019 08:50:09 -0400 Subject: [PATCH 09/11] Update main.py --- main.py | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index d9884422..fa933b54 100644 --- a/main.py +++ b/main.py @@ -83,6 +83,29 @@ def resumelist(code): return(sitedata) +def cleardata(): + runcheck = 0 + + while runcheck == 0: + + confirm = input("Are you sure you want to clear local data? Y or N.") + + if confirm == "Y": + try: + del storage['key'] + del storage['pstr'] + command = input("Cleared. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck += 1 + except (KeyError, IndexError, NameError, TypeError): + print("No data stored") + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck += 1 + elif confirm == "N": + command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck += 1 + else: + print("Sorry, command not recognized, please try again.") + command = input("Welcome! Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") try: @@ -90,7 +113,8 @@ def resumelist(code): sitedata = resumelist(resumecodeentered) key = storage['key'] -except KeyError: +except (KeyError, IndexError): + pass while running == 0: @@ -126,22 +150,7 @@ def resumelist(code): command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") elif command == "c": - - runcheck = 0 - - while runcheck == 0: - - confirm = input("Are you sure you want to clear local data? Y or N.") - - if confirm == "Y": - del storage['key'] - del storage['pstr'] - runcheck = 1 - elif confirm == "N": - command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - runcheck = 1 - else: - print("Sorry, command not recognized, please try again.") + cleardata() elif command == "q": printstring = "" From 6af2a6ef44463b40b46a70c6961a3543b819e473 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Thu, 30 May 2019 08:52:26 -0400 Subject: [PATCH 10/11] Update main.py --- main.py | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index fa933b54..234261db 100644 --- a/main.py +++ b/main.py @@ -83,28 +83,6 @@ def resumelist(code): return(sitedata) -def cleardata(): - runcheck = 0 - - while runcheck == 0: - - confirm = input("Are you sure you want to clear local data? Y or N.") - - if confirm == "Y": - try: - del storage['key'] - del storage['pstr'] - command = input("Cleared. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - runcheck += 1 - except (KeyError, IndexError, NameError, TypeError): - print("No data stored") - command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - runcheck += 1 - elif confirm == "N": - command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") - runcheck += 1 - else: - print("Sorry, command not recognized, please try again.") command = input("Welcome! Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords, or press q to exit: ") @@ -150,7 +128,27 @@ def cleardata(): command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") elif command == "c": - cleardata() + runcheck = 0 + + while runcheck == 0: + + confirm = input("Are you sure you want to clear local data? Y or N.") + + if confirm == "Y": + try: + del storage['key'] + del storage['pstr'] + command = input("Cleared. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck += 1 + except (KeyError, IndexError, NameError, TypeError): + print("No data stored") + command = input("Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck += 1 + elif confirm == "N": + command = input("Understood. Press s to store a site and password, press g to retrieve a site and password, press c to clear stored passwords or press q to exit: ") + runcheck += 1 + else: + print("Sorry, command not recognized, please try again.") elif command == "q": printstring = "" From ea9a7195e46ea99684143bfb350b6472e0306ab7 Mon Sep 17 00:00:00 2001 From: Spyglass117 <46973734+Spyglass117@users.noreply.github.com> Date: Thu, 6 Jun 2019 20:41:14 -0400 Subject: [PATCH 11/11] Update main.py --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index 234261db..5870595f 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,7 @@ +""" +Author name: Carlton Berthold +References: Mr. Dennison, Brython Documentation +""" import string import random from browser.local_storage import storage