Exercise 3. Password locker. 1. You probably have accounts on many different websites. It’s a bad habit to use the same password for each of them because if any of those sites has a security breach, the hackers will learn the password to all of your other accounts. Develop a simple password manager software on your computer where you write the account name (blog, facebook, instagram, etc) as an argument and the password is copied to the clipboard. Then you can paste it into the website’s Password field. For example, if you execute this command line in your terminal: python3 ./pw.py instagram The password for Instagram (example: htS:D`t*hQH3]9"C) should be copied to the clipboard.
2. Add a second argument where is a master password. Only copy to the clipboard the password for the first argument if the master password is correct.
#Homework 3, Exercise 3 #Jordan Eric Greenhut #9/22/2019 """this is a password locker for four websites. the dictionary increase in size though the sys.argv commands allow the website to be accessed from the commandline. the command pyperclip.paste then copies the password""" import pyperclip # library to copy password to clip board import sys # library to read commandline argument # dummy password dictionary psswdDict = { 'website1':12345, 'website2' :58946, 'website3' :48955, 'website4' :78493 } #if statement inspired by computer science stack exchange #link: https://stackoverflow.com/questions/54878410/automate-the-boring-stuff-chapter-6-password-locker if len(sys.argv) <2: print('Usage: python pw.py [account] - copy account password') sys.exit() # read the website to be used from commandline choice = sys.argv[1] password = psswdDict[choice] # copy the password to the clipboard pyperclip.copy(str(password)) spam = pyperclip.paste() #end of the programcount)
Just do part 2. Here is the code for part 1
If you have any doubts, please give me comment...
#Homework 3, Exercise 3
#Jordan Eric Greenhut
#9/22/2019
"""this is a password locker for four websites. the dictionary increase in size though
the sys.argv commands allow the website to be accessed from the commandline. the command pyperclip.paste
then copies the password"""
import pyperclip # library to copy password to clip board
import sys # library to read commandline argument
# dummy password dictionary
psswdDict = {
'website1':12345,
'website2' :58946,
'website3' :48955,
'website4' :78493
}
#if statement inspired by computer science stack exchange
#link: https://stackoverflow.com/questions/54878410/automate-the-boring-stuff-chapter-6-password-locker
if len(sys.argv) <3:
print('Usage: python pw.py [account] [master password]- copy account password')
sys.exit()
# read the website to be used from commandline
if sys.argv[2] == "admin123":
choice = sys.argv[1]
password = psswdDict[choice]
# copy the password to the clipboard
pyperclip.copy(str(password))
spam = pyperclip.paste()
else:
print("failed! wrong master password")
#end of the programcount)
Get Answers For Free
Most questions answered within 1 hours.