Test119 2
Test119 2
no Contents Pg no Signature
1. Introduction 1
2. Synopsis 2
3. Objective of the program 3
4. Errors and its types 4
5. Testing 5
6. Maintenance 6
7. Modules used 7
8. Function used 8
9. System requirements 9
14. Conclusion 17
14. Bibliography 19
INDEX
INTRODUCTION:
SYNOPSIS:
1
This Password Management System is a Python-based
project that allows users to securely store, retrieve, and
manage passwords for different websites. The system uses
encryption techniques to ensure that passwords are stored
safely and cannot be accessed without proper decryption. This
project aims to address the common need for secure password
storage while providing an easy-to-use interface for interacting
with stored credentials.
1. Password Encryption:
2. Password Storage:
3. Password Retrieval:
4. Key Management:
2
The primary objective of this Password Management
System project is to develop a secure, simple, and easy-to-use
tool that allows users to store, manage, and retrieve their
passwords safely. The system uses encryption techniques to
protect sensitive password data, ensuring that it is not exposed
in plain text, even if the storage file is compromised.
Specific Objectives:
3
o Serve as an educational tool to demonstrate secure
password handling, file I/O in Python, and basic
cryptographic techniques to students or beginners
learning about data security.
4
An error, sometime called “A BUG” is anything in the code that
prevents a program from compiling and running correctly.
TESTING:
5
1. Alpha Testing: It is the most common type of testing used
in the software industry. The objective of this testing is to
identify all possible issues or defects before releasing it into the
market or to the user. It is conducted at the developer’s site.
MAINTENANCE
7
MODULES USED
1. os Module
2. random Module
3. cryptography.fernet Module
4. string Module
8
FUNCTIONS USED
1. generate_key()
2. load_key()
3. encrypt_text(password)
4. decrypt_password(encrypted_password)
6. retrieve_password(website, key)
7. main()
9
SYSTEM REQUIREMENTS
HARDWARE:-
✓ Processor
✓ Keyboard
✓ Minimum memory - 2GB
SOFTWARE:-
✓ Operating System –OS10, OS11
✓ Python IDL
10
FLOWCHART
11
SOURCE CODE
import random
import string
import os
def generate_key():
if not os.path.exists("key.key"):
key = Fernet.generate_key()
key_file.write(key)
else:
key = key_file.read()
return key
12
def encrypt_text(text):
key = generate_key()
f = Fernet(key)
encrypted_text = f.encrypt(text.encode())
return encrypted_text
def decrypt_text(encrypted_text):
key = generate_key()
f = Fernet(key)
decrypted_text = f.decrypt(encrypted_text.encode()).decode()
return decrypted_text
def generate_easy_password(length=8):
def generate_complicated_password(length=12):
13
return ''.join(random.choice(characters) for _ in range(length))
encrypted_password = encrypt_text(password)
file.write(f"{subject}:{encrypted_password.decode()}\n")
def generate_and_save_password():
while True:
if choice == 'easy':
14
password = generate_easy_password()
break
password = generate_complicated_password()
break
else:
if save_choice == 'yes':
save_password(subject, password)
else:
15
def view_passwords(filename="passwords.txt"):
if not os.path.exists(filename):
else:
passwords = file.readlines()
if passwords:
print("Saved Passwords:")
try:
subject, encrypted_password =
entry.strip().split(":")
decrypted_password =
decrypt_text(encrypted_password)
print(f"{subject}: {decrypted_password}")
except ValueError:
while True:
print("\nPassword Manager")
print("4. Exit")
o = input('enter option:')
if o == '1':
generate_and_save_password()
elif o == '2':
save_password(sub,pin)
17
elif o == '3':
view_passwords()
elif o == '4':
print('tq')
break
18
OUTPUT
19
CONCLUSION
The Password Management System implemented in Python
successfully demonstrates the principles of secure password
storage and encryption using the cryptography.fernet
module. This project highlights key concepts in data security
and provides a basic yet functional tool to manage passwords
safely.
Key Achievements:
20
o By encrypting passwords with a secret key and
ensuring that the key is separate from the data, the
system protects sensitive information from
unauthorized access. However, it also emphasizes
the importance of securely managing the encryption
key.
1. Key Management:
o The security of the system depends on how well the
secret.key file is protected. If the key is lost or
compromised, the entire system's security is at risk.
Future versions could include methods to securely
store or generate keys, such as integrating password
protection for the key itself.
2. User Authentication:
o The current system lacks authentication features. To
enhance security, future versions could require a
master password to access the password manager,
ensuring only authorized users can view or modify
stored passwords.
3. Password Strength:
o The system does not currently check or enforce
password strength. Adding a password strength
checker to ensure users are choosing strong, secure
passwords would be an important improvement.
4. Advanced Features:
o The system can be extended to include additional
features, such as:
Password generation tools for automatically
creating strong passwords.
Cloud synchronization for accessing passwords
across multiple devices.
Graphical user interface (GUI) for a more user-
friendly experience.
21
BIBLIOGRAPHY
https://www.interviewbit.com/blog/python-projects/
https://www.w3schools.com/python/
https://pythonworld.in/practical-project/project-list/
import random
import string
import os
from cryptography.fernet import
Fernet
def generate_key():
if not os.path.exists("key.key"):
key = Fernet.generate_key()
with open("key.key", "wb") as
key_file:
key_file.write(key)
else:
with open("key.key", "rb") as
key_file:
key = key_file.read()
return key
22
def encrypt_text(text):
key = generate_key()
f = Fernet(key)
encrypted_text =
f.encrypt(text.encode())
return encrypted_text
def decrypt_text(encrypted_text):
key = generate_key()
f = Fernet(key)
decrypted_text =
f.decrypt(encrypted_text.encode()).d
ecode()
return decrypted_text
def
generate_easy_password(length=8):
characters = string.ascii_lowercase
+ string.digits
return
''.join(random.choice(characters) for
_ in range(length))
def
generate_complicated_password(len
gth=12):
characters = string.ascii_letters +
string.digits + string.punctuation
return
''.join(random.choice(characters) for
_ in range(length))
23
def save_password(subject,
password,
filename="passwords.txt"):
encrypted_password =
encrypt_text(password)
with open(filename, "a") as file:
file.write(f"{subject}:
{encrypted_password.decode()}\n")
print(f"\nPassword for {subject}
saved successfully!")
def generate_and_save_password():
# Function to generate and save
password
subject = input("Enter the subject
name (e.g., email, bank account): ")
while True:
choice = input("Choose password
complexity (easy/complicated):
").strip().lower()
if choice == 'easy':
password =
generate_easy_password()
break
elif choice == 'complicated':
24
password =
generate_complicated_password()
break
else:
print("Invalid choice. Please
choose 'easy' or 'complicated'.")
def
view_passwords(filename="passwor
ds.txt"):
25
if not os.path.exists(filename):
print("No saved passwords
found.")
else:
with open(filename, "r") as file:
passwords = file.readlines()
if passwords:
print("Saved Passwords:")
for entry in passwords:
try:
subject,
encrypted_password =
entry.strip().split(":")
decrypted_password =
decrypt_text(encrypted_password)
print(f"{subject}:
{decrypted_password}")
except ValueError:
print("Error reading
entry, invalid format.")
else:
print("No passwords saved
yet.")
input("\nPress Enter to return to
the menu...")
while True:
print("\nPassword Manager")
26
print("1. Generate and Save
Password")
print("2. Manual Save Password")
print("3. View Saved Passwords")
print("4. Exit")
o = input('enter option:')
if o == '1':
generate_and_save_password()
elif o == '2':
sub = input('Enter subject:')
pin = input('enter pin:')
save_password(sub,pin)
elif o == '3':
view_passwords()
elif o == '4':
print('tq')
break
27