Mini Project Report-1
Mini Project Report-1
Mini Project Report-1
A DISSERTATION REPORT ON
BACHELOR OF ENGINEERING
IN
COMPUTER ENGINEERING
GROUP MEMEBERS
Dipti Raut
I declare that this written submission represents my ideas in my own words and where others'
ideas or words have been included, I have adequately cited and referenced the original
sources. I also declare that I have adhered to all principles of academic honesty and integrity
and have not misrepresented or fabricated or falsified any idea/data/fact/source in my
submission. I understand that any violation of the above will be cause for disciplinary action
by the Institute and can also evoke penal action from the sources which have thus not been
properly cited or from whom proper permission has not been taken when needed.
Date:
Place: SHELU
PROJECT REPORT APPROVAL FOR S.E.
This project report entitled “File Encryption and Decryption Using AES Algorithm” by
“Rajshree Borkar (03)”, “Ashish Gavade (08)”, “Shubham Khedeker (21)”, “SK
Mohmad Amjad Raza (49)” is approved for the degree of “Second Year of Computer
Engineering”.
Examiners
1.
2.
Date:
Place: SHELU
CERTIFICATE
This is to certify that the project entitled “File Encryption and Decryption Using AES
Algorithm” is a bonafide work of “Rajshree Borkar (03)”, “Ashish Gavade (08)”,
“Shubham Khedeker (21)”, “SK Mohmad Amjad Raza (49)”, “submitted to the
University of Mumbai in partial fulfillment of the requirement for the award of the degree of
“Undergraduate” in “Second Year of Computer Engineering”.
We have immense pleasure in presenting the report for our project entitled “File Encryption and
Decryption Using AES Algorithm”.
We would like to take this opportunity to express our gratitude to a number of people
who have been sources of help & encouragement during the courses of this project.
We are very graceful and indebted to our project guide & our respected HOD for
providing their enduring patience, guidance, & suggestions. They were the one who
never let our morale down & always supported us through our thick & thin. They were
the constant source of inspiration for us & took at most interest in our project.
We would also like to thank all the staff members for their invaluable co-operation &
permitting us to work in the computer lab.
We are also thankful to all the students for giving us their useful advice & immense co-
operation. Their support made the working of this project very pleasant.
Group Members
Rajshree Borkar (03)
2. IMPLEMENTED SYSTEM
2.1 Introduction
2.2 System Architecture
3. PROJECT DESIGN
3.1 Flow Chart
3.2 Sequence Diagram
3.3 Use-Case Diagram
4. CODING
5. SNAPSHOTS
6. TESTING
6.1 SOFTWARE TESTING
6.1.1 System Testing
6.1.2 Unit Testing
6.1.3 Integration Testing
6.1.4 Functional Testing
6.2 Testing Method
6.2.1 Black Box Testing
6.2.2 White Box Testing
7. ADVANTAGES & DISADVANTAGES
8. CONCLUSION & FUTURE SCOPE
9. REFERENCES
ABSTRACT
Data security is a major issue which we are facing today in this digital world
of communication. As we know that today hackers are almost at every corner in search
of our useful data which can be hacked by them for their different purposes. Even the
risk gets doubled when come to the data of any country’s government. So, a system or
terminology is must require to make that data safe forever by any means during
communication.
In the application the user has to select either wants to send something by
encrypting or wants to receive by decrypting. If it wants to send then it has to select
source file previously designed or type some message which is to Encrypt and then
transfer. Whereas on the receiver side again the receiver has to select the file which is
to be received from the sender along with a decryption key to decrypt that message.
Decryption key can be selected either manually if told by the sender or selecting key
sent by the sender along with the encrypted data to avoid further delay in processing
the message.
INTRODUCTION
1.1 Overview:
This project is all about the Data Security. How we can secure our data from hackers.
The symmetric-key block cipher plays an important role in data encryption. It means that the
same key is used for both encryption and decryption. The Advanced Encryption Standard
(AES) is a widely used symmetric-key encryption algorithm.
In this project, we’ll see how to implement AES encryption and decryption using the Python on the
any kind of files using pycryptodomex package.
As we know that today hackers are almost at every corner in search of our useful data
which can be hacked by them for their different purposes. Even the risk gets doubled when
come to the data of any country’s government. So, a system or terminology is must require to
make that data safe forever by any means during communication. So the main aim of the
project is to secure our important data from hackers and keep it safe.
Many organizations today are facing difficulties in choosing the best encryption and
decryption algorithms for incorporating data security, confidentiality, and integrity in their
businesses. Organizations need huge budget for analyzing the encryption processing
overhead of a variety of cryptographic algorithms that are available in the market today
Decryption:
It is generally a reverse process of encryption. It decodes the encrypted information so
that an authorized user can only decrypt the data because decryption requires a secret key or
password.
2.2 SYSTEM ARCHITECTURE
System architecture is the conceptual model that defines the structure, behavior,
and more views of a system. An architecture description is a formal description and
representation of a system, organized in a way that supports reasoning about the structures
and behaviors of the system.
In our system architecture, sender send any kind of file it can be text, image, excel,
etc., the file which we have to encrypt and we have to set an encryption key for encrypted
method. After encryption the cipher data is used for decryption of file data in which we have
to copy the encrypted file and then enter the key set while encryption and the encrypted file
will be decrypted into its original form.
PROJECT DESIGN
Encryption:-
Decryption:-
3.2 Sequence Diagram:
A sequence diagram simply depicts interaction between objects in a sequential order i.e. the
order in which these interactions take place. We can also use the terms event diagrams or
event scenarios to refer to a sequence diagram. Sequence diagrams describe how and in what
order the objects in a system function.
In this sequential diagram, sender send any kind of file it can be text, image, excel, etc., the
file which we have to encrypt and we have to set an encryption key for encrypted method.
After encryption the cipher data is used for decryption of file data in which we have to copy
the encrypted file and then enter the key set while encryption and the encrypted file will be
decrypted into its original form.
3.3 Use -Case Diagram:
A use case is a methodology used in system analysis to identify, clarify and organize system
requirements. The use case is made up of a set of possible sequences of interactions between
systems and users in a particular environment and related to a particular goal.
In this, sender sends the file (text file, image file etc.), the file which we have to encrypt and
we have to set an encryption key for encryption logic. After encryption the cipher data is used
for decryption of file in which we have to drive the encrypted file and then enter the key set
while encryption and the encrypted file will be decrypted.
CODING
Encryption File:-
import os
import sys
import hashlib
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
from Cryptodome.Cipher import AES
class EncryptionTool:
while True:
data = file_object.read(chunk_size)
if not data:
break
yield data
def encrypt(self):
cipher_object = AES.new(
self.hashed_key_salt["key"],
AES.MODE_CFB,
self.hashed_key_salt["salt"]
)
self.abort()
input_file.close()
output_file.close()
del cipher_object
def abort(self):
if os.path.isfile(self.encrypt_output_file):
os.remove(self.encrypt_output_file)
def hash_key_salt(self):
hasher = hashlib.new(self.hash_type)
hasher.update(self.user_key)
self.hashed_key_salt["key"] = bytes(hasher.hexdigest()[:32],
"utf-8")
del hasher
hasher = hashlib.new(self.hash_type)
hasher.update(self.user_salt)
self.hashed_key_salt["salt"] = bytes(hasher.hexdigest()[:16],
"utf-8")
del hasher
class MainWindow:
THIS_FOLDER_G = ""
if getattr(sys, "frozen", False):
THIS_FOLDER_G = os.path.dirname(sys.executable)
else:
THIS_FOLDER_G = os.path.dirname(os.path.realpath( file ))
self.should_cancel = False
root.title("FILE ENCYPTION")
root.configure(bg="#FCE0E8")
try:
icon_img = tk.Image(
"photo",
file=self.THIS_FOLDER_G + "/assets/icon.png"
)
root.call(
"wm",
"iconphoto",
root._w,
icon_img
)
except Exception:
pass
self.menu_bar = tk.Menu(
root,
bg="#FCE0E8",
relief=tk.FLAT
)
self.menu_bar.add_command( label="Help
", command=self.show_help_callback
)
self.menu_bar.add_command( label=
"Exit", command=root.quit
)
root.configure( menu=s
elf.menu_bar
)
self.file_entry_label = tk.Label(
root,
text="Enter File Path Or Click DERIVE FILE Button",
bg="#FCE0E8",
anchor=tk.W
)
self.file_entry_label.grid( padx=
12,
pady=(8, 0),
ipadx=0,
ipady=1,
row=0,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.file_entry = tk.Entry(
root,
textvariable=self._file_url,
bg="#fff",
exportselection=0,
relief=tk.FLAT
)
self.file_entry.grid(
padx=15,
pady=6,
ipadx=8,
ipady=8,
row=1,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.select_btn = tk.Button(
root,
text="DERIVE FILE",
command=self.selectfile_callback,
width=42,
bg="#1089ff",
fg="#ffffff",
bd=2,
relief=tk.FLAT
)
self.select_btn.grid(
padx=15,
pady=8,
ipadx=24,
ipady=6,
row=2,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.key_entry_label = tk.Label(
root,
text="Enter Secret Key",
bg="#FCE0E8",
anchor=tk.W
)
self.key_entry_label.grid( padx=1
2,
pady=(8, 0),
ipadx=0,
ipady=1,
row=3,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.key_entry = tk.Entry(
root,
textvariable=self._secret_key,
bg="#fff",
exportselection=0,
relief=tk.FLAT
)
self.key_entry.grid(
padx=15, pady=6,
ipadx=8,
ipady=8,
row=4,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.encrypt_btn = tk.Button(
root,
text="ENCRYPT FILE",
command=self.encrypt_callback,
bg="#FF2428",
fg="#ffffff",
bd=2,
relief=tk.FLAT
)
self.encrypt_btn.grid(
padx=(120, 6),
pady=8,
ipadx=24,
ipady=6,
row=7,
column=0,
columnspan=2,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.reset_btn = tk.Button(
root,
text="RESET",
command=self.reset_callback,
bg="#676767",
fg="#ffffff",
bd=2,
relief=tk.FLAT
)
self.reset_btn.grid(
padx=15,
pady=(4, 12),
ipadx=24,
ipady=6,
row=8,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.status_label = tk.Label(
root,
textvariable=self._status,
bg="#FCE0E8",
anchor=tk.W,
justify=tk.LEFT,
relief=tk.FLAT,
wraplength=350
)
self.status_label.grid(
padx=12,
pady=(0, 12),
ipadx=0,
ipady=1,
row=9,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
tk.Grid.columnconfigure(root, 0, weight=1)
tk.Grid.columnconfigure(root, 1, weight=1)
tk.Grid.columnconfigure(root, 2, weight=1)
tk.Grid.columnconfigure(root, 3, weight=1)
def selectfile_callback(self):
try:
name = filedialog.askopenfile()
self._file_url.set(name.name) #
print(name.name)
except Exception as e:
self._status.set(e)
self.status_label.update()
def freeze_controls(self):
self.file_entry.configure(state="disabled")
self.key_entry.configure(state="disabled")
self.select_btn.configure(state="disabled")
self.encrypt_btn.configure(state="disabled")
self.reset_btn.configure(text="CANCEL",
command=self.cancel_callback,
fg="#ed3833", bg="#fafafa")
self.status_label.update()
def unfreeze_controls(self):
self.file_entry.configure(state="normal")
self.key_entry.configure(state="normal")
self.select_btn.configure(state="normal")
self.encrypt_btn.configure(state="normal")
self.reset_btn.configure(text="RESET",
command=self.reset_callback,
fg="#ffffff", bg="#676767")
self.status_label.update()
def encrypt_callback(self):
self.freeze_controls()
try:
self._cipher = EncryptionTool(
self._file_url.get(),
self._secret_key.get(),
self._salt.get()
)
for percentage in self._cipher.encrypt():
if self.should_cancel:
break
percentage = "{0:.2f}%".format(percentage)
self._status.set(percentage)
self.status_label.update()
self._status.set("Your File is Encrypted!")
if self.should_cancel:
self._cipher.abort()
self._status.set("Cancelled!")
self._cipher = None
self.should_cancel = False
except Exception as e:
self._status.set(e)
self.unfreeze_controls()
def reset_callback(self):
self._cipher = None
self._file_url.set("")
self._secret_key.set("")
self._salt.set("")
self._status.set("")
def cancel_callback(self):
self.should_cancel = True
def show_help_callback(self):
messagebox.showinfo(
"Help",
"""1. Open the App and Click SELECT FILE Button and
select your file e.g. "abc.jpg".
4. Click RESET Button to reset the input fields and status bar.
class EncryptionTool:
self.input_file_size = os.path.getsize(self.user_file)
self.chunk_size = 1024
self.total_chunks = (self.input_file_size // self.chunk_size)
+ 1
self.file_extension = self.user_file.split(".")[-1]
self.hash_type = "SHA256"
self.encrypt_output_file =
".".join(self.user_file.split(".")[:-1]) \
+ "." + self.file_extension + ".encr"
self.decrypt_output_file = self.user_file[:-5].split(".")
self.decrypt_output_file =
".".join(self.decrypt_output_file[:-1]) \
+ "_Decrypted_." + self.decrypt_output_file[-1]
self.hashed_key_salt = dict()
self.hash_key_salt()
while True:
data = file_object.read(chunk_size)
if not data:
break
yield data
def decrypt(self):
cipher_object = AES.new(
self.hashed_key_salt["key"],
AES.MODE_CFB,
self.hashed_key_salt["salt"]
)
self.abort()
input_file.close()
output_file.close()
del cipher_object
def abort(self):
if os.path.isfile(self.decrypt_output_file):
os.remove(self.decrypt_output_file)
def hash_key_salt(self):
hasher = hashlib.new(self.hash_type)
hasher.update(self.user_key)
self.hashed_key_salt["key"] = bytes(hasher.hexdigest()[:32],
"utf-8")
del hasher
hasher = hashlib.new(self.hash_type)
hasher.update(self.user_salt)
self.hashed_key_salt["salt"] = bytes(hasher.hexdigest()[:16],
"utf-8")
del hasher
class MainWindow:
THIS_FOLDER_G = ""
if getattr(sys, "frozen", False):
THIS_FOLDER_G = os.path.dirname(sys.executable)
else:
THIS_FOLDER_G = os.path.dirname(os.path.realpath( file ))
self.should_cancel = False
root.title("FILE DECRYPTION")
root.configure(bg="#FCE0E8")
try:
icon_img = tk.Image(
"photo",
file=self.THIS_FOLDER_G + "/assets/icon.png"
)
root.call(
"wm",
"iconphoto",
root._w,
icon_img
)
except Exception:
pass
self.menu_bar = tk.Menu(
root,
bg="#FCE0E8",
relief=tk.FLAT
)
self.menu_bar.add_command( label="Help
", command=self.show_help_callback
)
self.menu_bar.add_command( label=
"Exit", command=root.quit
)
root.configure( menu=s
elf.menu_bar
)
self.file_entry_label = tk.Label(
root,
text="Enter File Path Or Click DERIVE FILE Button",
bg="#FCE0E8",
anchor=tk.W
)
self.file_entry_label.grid( padx=
12,
pady=(8, 0),
ipadx=0,
ipady=1,
row=0,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.file_entry = tk.Entry(
root,
textvariable=self._file_url,
bg="#fff",
exportselection=0,
relief=tk.FLAT
)
self.file_entry.grid(
padx=15,
pady=6,
ipadx=8,
ipady=8,
row=1,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.select_btn = tk.Button(
root,
text="DERIVE ENCRYPTED FILE",
command=self.selectfile_callback,
width=42,
bg="#1089ff",
fg="#ffffff",
bd=2,
relief=tk.FLAT
)
self.select_btn.grid(
padx=15,
pady=8,
ipadx=24,
ipady=6,
row=2,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.key_entry_label = tk.Label(
root,
text="Enter Secret Key",
bg="#FCE0E8",
anchor=tk.W
)
self.key_entry_label.grid( padx=1
2,
pady=(8, 0),
ipadx=0,
ipady=1,
row=3,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.key_entry = tk.Entry(
root,
textvariable=self._secret_key,
bg="#fff",
exportselection=0,
relief=tk.FLAT
)
self.key_entry.grid(
padx=15, pady=6,
ipadx=8,
ipady=8,
row=4,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.decrypt_btn = tk.Button(
root,
text="DECRYPT FILE",
command=self.decrypt_callback,
bg="#0FCD00",
fg="#ffffff",
bd=2,
relief=tk.FLAT
)
self.decrypt_btn.grid(
padx=(6, 120),
pady=8,
ipadx=24,
ipady=6,
row=7,
column=2,
columnspan=2,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.reset_btn = tk.Button(
root,
text="RESET",
command=self.reset_callback,
bg="#676767",
fg="#ffffff",
bd=2,
relief=tk.FLAT
)
self.reset_btn.grid(
padx=15,
pady=(4, 12),
ipadx=24,
ipady=6,
row=8,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
self.status_label = tk.Label(
root,
textvariable=self._status,
bg="#FCE0E8",
anchor=tk.W,
justify=tk.LEFT,
relief=tk.FLAT,
wraplength=350
)
self.status_label.grid(
padx=12,
pady=(0, 12),
ipadx=0,
ipady=1,
row=9,
column=0,
columnspan=4,
sticky=tk.W+tk.E+tk.N+tk.S
)
tk.Grid.columnconfigure(root, 0, weight=1)
tk.Grid.columnconfigure(root, 1, weight=1)
tk.Grid.columnconfigure(root, 2, weight=1)
tk.Grid.columnconfigure(root, 3, weight=1)
def selectfile_callback(self):
try:
name = filedialog.askopenfile()
self._file_url.set(name.name) #
print(name.name)
except Exception as e:
self._status.set(e)
self.status_label.update()
def freeze_controls(self):
self.file_entry.configure(state="disabled")
self.key_entry.configure(state="disabled")
self.select_btn.configure(state="disabled")
self.decrypt_btn.configure(state="disabled")
self.reset_btn.configure(text="CANCEL",
command=self.cancel_callback,
fg="#ed3833", bg="#fafafa")
self.status_label.update()
def unfreeze_controls(self):
self.file_entry.configure(state="normal")
self.key_entry.configure(state="normal")
self.select_btn.configure(state="normal")
self.decrypt_btn.configure(state="normal")
self.reset_btn.configure(text="RESET",
command=self.reset_callback,
fg="#ffffff", bg="#676767")
self.status_label.update()
def decrypt_callback(self):
self.freeze_controls()
try:
self._cipher = EncryptionTool(
self._file_url.get(),
self._secret_key.get(),
self._salt.get()
)
for percentage in self._cipher.decrypt():
if self.should_cancel:
break
percentage = "{0:.2f}%".format(percentage)
self._status.set(percentage)
self.status_label.update()
self._status.set("Your File is Decrypted!")
if self.should_cancel:
self._cipher.abort()
self._status.set("Cancelled!")
self._cipher = None
self.should_cancel = False
except Exception as e:
self._status.set(e)
self.unfreeze_controls()
def reset_callback(self):
self._cipher = None
self._file_url.set("")
self._secret_key.set("")
self._salt.set("")
self._status.set("")
def cancel_callback(self):
self.should_cancel = True
def show_help_callback(self):
messagebox.showinfo(
"Help",
"""1. Open the App and Click SELECT FILE Button and
select Encrypted file e.g. "abc.jpg".
4. When you want to Decrypt a file you, will select the file with the
".encr" extention and Enter your Secret Key which you chose at the
time of Encryption. Click DECRYPT Button to decrypt. The decrypted
file will be of the same name as before with the suffix "_Decrypted_"
e.g. "abc_Decrypted_.jpg".
Click RESET Button to reset the input fields and status bar.
Final Output was the Decrypted file with the suffix "_Decrypted_" :-
SOFTWARE TESTING
As the number of possible tests for even simple software components is practically
infinite, all software testing uses some strategy to select tests that are feasible for the
available time and resources. As a result, software testing typically (but not exclusively)
attempts to execute a program or application with the intent of finding software bugs (errors
or other defects). The job of testing is an iterative process as when one bug is fixed; it can
illuminate other, deeper bugs, or can even create new ones.
Software testing can provide objective, independent information about the quality of
software and risk of its failure to users or sponsors.
As a rule, system testing takes, as its input, all of the "integrated" software
components that have passed integration testing and also the software system itself integrated
with any applicable hardware system(s). The purpose of integration testing is to detect any
inconsistencies between the software units that are integrated together (called assemblages)
or between any of the assemblages and the hardware. System testing is a more limited type of
testing; it seeks to detect defects both within the "inter-assemblages" and also within the
system as a whole.
Unit Testing is a software testing method by which individual units of source code,
sets of one or more computer program modules together with associated control data, usage
procedures, and operating procedures, are tested to determine whether they are fit for use.
Intuitively, one can view a unit as the smallest testable part of an application. In procedural
programming, a unit could be an entire module, but it is more commonly an individual
function or procedure. In object-oriented programming, a unit is often an entire interface,
such as a class, but could be an individual method.
Unit tests are short code fragments created by programmers or occasionally by white
box testers during the development process. It forms the basis for component testing. Ideally,
each test case is independent from the others. Substitutes such as method stubs, mock objects,
fakes, and test harnesses can be used to assist testing a module in isolation. Unit tests are
typically written and run by software developers to ensure that code meets its design and
behaves as intended.
Integration testing (sometimes called integration and testing, abbreviated I&T) is the
phase in software testing in which individual software modules are combined and tested as a
group. It occurs after unit testing and before validation testing. Integration testing takes as its
input modules that have been unit tested, groups them in larger aggregates, applies tests
defined in an integration test plan to those aggregates, and delivers as its output the integrated
system ready for system testing.
Functional testing is a quality assurance (QA) process and a type of black-box testing
that bases its test cases on the specifications of the software component under test. Functions
are tested by feeding them input and examining the output, and internal program structure is
rarely considered Functional testing usually describes what the system does.
Functional testing does not imply that you are testing a function (method) of your module or
class. Functional testing tests a slice of functionality of the whole system.
6.2Testing Method:
The tester chooses inputs to exercise paths through the code and determine the
appropriate outputs. While white-box testing can be applied at
the unit, integration and system levels of the software testing process, it is usually done at the
unit level. It can test paths within a unit, paths between units during integration, and between
subsystems during a system–level test. Though this method of test design can uncover many
errors or problems, it might not detect unimplemented parts of the specification or missing
requirements.
ADVANTAGES & DISADVANTAGES
Yenuguvanilanka. J., & Elkeelany, O. (2008. April). Performance evaluation of hardware models
of Advanced Encryption Standard (AES) algorithm. In Southeastcon, 2008. IEEE (pp. 222-225).
Lu. C. C.. & Tseng, S. Y. (2002). Integrated design of AES (Advanced Encryption Standard)
Mohamed. A. A., & Madian, A. H. (2010. December). A Modified Rijndael Algorithm and its
Implementation using FPGA. In Electronics. Circuits, and Systems (ICECS), 2010 17th IEEE
Deshpande. H. S., Karande, K. J., & Mulani, A. 0. (2014. April). Efficient implementation of
AES algorithm on FPGA. In Communications and Signal Processing (ICCSP), 2014 IEEE