Jaypee Institute of Information Technology
Information Security Lab
Password Manager using AES Encryption in Python
Submitted to Professor Dr. Raghu Vamsi Pottukuchi
Submitted By:
Barbie Agrawal 21103032
Anubhav Goel 21103045
Sparsh Kumar 21103054
Batch: B2
1
Table of Contents
Title 3
Problem Statement 3
Introduction to our Project 4
Flowchart 5
Code 6
Screenshots 9
References 10
2
Title
Password Manager using AES Encryption in Python
Problem Statement
Managing passwords in the current age has become a tedious task in itself. People sign up for
tons of social media, different applications, shopping sites, games etc. and it is hard to keep track
of passwords for all these different utilities.
Having the same password everywhere is an easy solution to remembering passwords but it also
comes at the cost of a massive security concern. One password being cracked would mean a
compromise on all of your other accounts.
Thus, coming up with a different and unique set of passwords for different accounts is also a
problem that needs to be tackled in the modern era.
3
Introduction to our Project
For our Information Security lab project, we have developed a password manager in Python which
uses AES encryption from Python’s [Link] module.
Our project is a command-line utility (CLI) with which users can save passwords for different
sites. They have two options -
● Manually enter password
● Generate password
On entering, we give a user 4 options to use the program -
1. Add or update a password
2. Look up a previously stored password
3. Delete a stored password
4. Exit program
4
Flowchart
AES Encryption -
5
Code
import os
import json
import sys
import getpass
from [Link] import isfile
from hashlib import sha256
from termcolor import colored
from halo import Halo
from [Link] import DataManip
from [Link] import UserExits, PasswordFileDoesNotExist
from [Link] import Manager
def exitProgram():
print(colored("Exiting...", "red"))
[Link]()
def start(obj: DataManip):
if [Link]("db/[Link]"):
with open("db/[Link]", 'r') as jsondata:
jfile = [Link](jsondata)
storedMasterPass = jfile["Master"]
masterPass = [Link]("Enter Your Master Password: ")
spinner = Halo(text=colored("Unlocking", "green"),
color="green", spinner=obj.dots_)
if sha256([Link]("utf-8")).hexdigest() == storedMasterPass:
print(
colored(f"{obj.checkmark_} Thank you! Choose an option below:", "green"))
6
menu = Manager(obj, "db/[Link]",
"db/[Link]", masterPass)
try:
[Link]()
except UserExits:
exitProgram()
except PasswordFileDoesNotExist:
print(colored(
f"{obj.x_mark_} DB not found. Try adding a password {obj.x_mark_}", "red"))
else:
print(
colored(f"{obj.x_mark_} Master password is incorrect {obj.x_mark_}", "red"))
return start(obj)
else:
try:
[Link]("db/")
except FileExistsError:
pass
print(colored("To start, we'll have you create a master password. Be careful not to lose it as it is
unrecoverable.", "green"))
masterPass = [Link](
"Create a master password for the program: ")
secondInput = [Link]("Verify your master pasword: ")
if masterPass == secondInput:
spinner = Halo(text=colored("initializing base...",
"green"), color="green", spinner=obj.dots_)
hashMasterPass = sha256([Link]("utf-8")).hexdigest()
jfile = {"Master": {}}
jfile["Master"] = hashMasterPass
with open("db/[Link]", 'w') as jsondata:
7
[Link](jfile, jsondata, sort_keys=True, indent=4)
[Link]()
print(colored(
f"{obj.checkmark_} Thank you! Restart the program and enter your master password to
begin.", "green"))
else:
print(colored(
f"{obj.x_mark_} Passwords do not match. Please try again {obj.x_mark_}", "red"))
return start(obj)
if __name__ == "__main__":
obj = DataManip()
start(obj)
8
Screenshots
9
10
References
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
11