Aug-16-2017, 01:02 AM
I have an assignment to write code for Choice 2, to 1. create a loop that goes through each item in the password list; 2. Check if the name is found; 3. if the name is found, decrypt it. Some of the instructions are already in the code and the code that I have attempted is located right after the ###### YOUR CODE HERE ###### entry. For Choice 3, I need to encrypt the password and store it in the list of passwords. I have also entered code for Choice 3 but it is also not working. Any help you can give me would be greatly appreciate.
#The password list - We start with it populated for testing purposes
passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]]
if(choice == '2'): #Lookup at password
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
####### YOUR CODE HERE ######
for i in range (len(passwords)): #Create a loop that goes through each item in the password list
i = [0, 1]
#You will need to find the password that matches the website
#You will then need to decrypt the password
#
#1. Create a loop that goes through each item in the password list
# You can consult the reading on lists in Week 5 for ways to loop through a list
#
#2. Check if the name is found. To index a list of lists you use 2 square backet sets
# So passwords[0][1] would mean for the first item in the list get it's 2nd item (remember, lists start at 0)
# So this would be 'XqffoZeo' in the password list given what is predefined at the top of the page.
# If you created a loop using the syntax described in step 1, then i is your 'iterator' in the list so you
# will want to use i in your first set of brackets.
#
#3. If the name is found then decrypt it. Decrypting is that exact reverse operation from encrypting. Take a look at the
# caesar cypher lecture as a reference. You do not need to write your own decryption function, you can reuse passwordEncrypt
#
# Write the above one step at a time. By this I mean, write step 1... but in your loop print out every item in the list
# for testing purposes. Then write step 2, and print out the password but not decrypted. Then write step 3. This way
# you can test easily along the way.
#
####### YOUR CODE HERE ######
if(choice == '3'):
print("What website is this password for?")
website = input()
print("What is the password?")
unencryptedPassword = input()
####### YOUR CODE HERE ######
#You will need to encrypt the password and store it in the list of passwords
#The encryption function is already written for you
#Step 1: You can say encryptedPassword = passwordEncrypt(unencryptedPassword,encryptionKey)]
#the encryptionKey variable is defined already as 16, don't change this
#Step 2: create a list of size 2, first item the website name and the second item the password.
#Step 3: append the list from Step 2 to the password list
encryptedpassword = passwordEncrypt(unencryptedPassword, encryptionKey)
newPassword = [[website, encryptedpassword]]
passwords.append(newPassword)
####### YOUR CODE HERE ######
#The password list - We start with it populated for testing purposes
passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]]
if(choice == '2'): #Lookup at password
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
####### YOUR CODE HERE ######
for i in range (len(passwords)): #Create a loop that goes through each item in the password list
i = [0, 1]
#You will need to find the password that matches the website
#You will then need to decrypt the password
#
#1. Create a loop that goes through each item in the password list
# You can consult the reading on lists in Week 5 for ways to loop through a list
#
#2. Check if the name is found. To index a list of lists you use 2 square backet sets
# So passwords[0][1] would mean for the first item in the list get it's 2nd item (remember, lists start at 0)
# So this would be 'XqffoZeo' in the password list given what is predefined at the top of the page.
# If you created a loop using the syntax described in step 1, then i is your 'iterator' in the list so you
# will want to use i in your first set of brackets.
#
#3. If the name is found then decrypt it. Decrypting is that exact reverse operation from encrypting. Take a look at the
# caesar cypher lecture as a reference. You do not need to write your own decryption function, you can reuse passwordEncrypt
#
# Write the above one step at a time. By this I mean, write step 1... but in your loop print out every item in the list
# for testing purposes. Then write step 2, and print out the password but not decrypted. Then write step 3. This way
# you can test easily along the way.
#
####### YOUR CODE HERE ######
if(choice == '3'):
print("What website is this password for?")
website = input()
print("What is the password?")
unencryptedPassword = input()
####### YOUR CODE HERE ######
#You will need to encrypt the password and store it in the list of passwords
#The encryption function is already written for you
#Step 1: You can say encryptedPassword = passwordEncrypt(unencryptedPassword,encryptionKey)]
#the encryptionKey variable is defined already as 16, don't change this
#Step 2: create a list of size 2, first item the website name and the second item the password.
#Step 3: append the list from Step 2 to the password list
encryptedpassword = passwordEncrypt(unencryptedPassword, encryptionKey)
newPassword = [[website, encryptedpassword]]
passwords.append(newPassword)
####### YOUR CODE HERE ######