Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

AES_assignment

Views: 1008
1
#! /usr/bin/python3
2
3
import json
4
pwds = dict()
5
# get passphrase from user
6
try:
7
fp = open("passwords.dat","rb")
8
try:
9
# decrypt here.
10
# passwords is the decrypted content
11
pwds = json.loads(passwords)
12
13
except:
14
## exit (probably because passphrase is wrong)
15
fp.close()
16
except:
17
fp = open("passwords.dat","w")
18
fp.close()
19
20
21
while True:
22
choice = input("Enter command: A to add password, V to view passwords, Q to quit:\n")
23
if choice == 'A':
24
site = input("which site? ")
25
pwds[site] = input("which password? ")
26
if choice == 'V':
27
for k in pwds:
28
print("password to {} is {}.".format(k,pwds[k]))
29
if choice == 'Q':
30
break
31
fp = open("passwords.json","w")
32
json.dump(pwds,fp)
33
fp.close()
34
35
36
37