Mini
Mini
GAYATHRI S (727722EUCS050),
HAASHINI A (727722EUCS060),
GURURAGAVENDRA PS (727723EUCS501),
HEMANTH SURYA AS (727723EUCS503)
degree of
BACHELOR OF ENGINEERING
IN
An Autonomous Institution | Approved by AICTE | Affiliated to Anna University | Accredited by NAAC with A++ Grade
Kuniyamuthur, Coimbatore – 641008.
November 2024
SUSTAINABLE DEVELOPMENT GOALS
The Sustainable Development Goals are a collection of 17 global goals designed to blue print
to achieve a better and more sustainable future for all. The SDGs, set in 2015 by the United
Nations General Assembly and intended to be achieved by the year 2030, In 2015, 195 nations
agreed as a blue print that they can change the world for the better. The project is based on one
of the 17 goals.
SIGNATURE SIGNATURE
Dr. GRANTY REGINA ELWIN J Ms K.SUDHA
HEAD OF THE DEPARTMENT SUPERVISOR
Professor Professor
Computer Science and Engineering Computer Science and Engineering and
Sri Krishna College of Engineering and Sri Krishna College of Engineering and
Technology Technology
Kuniyamuthur, Coimbatore–641008. Kuniyamuthur, Coimbatore–641008.
TABLE OF CONTENTS
ABSTRACT iv
LIST OF TABLES vii
LIST OF FIGURES viii
1. INTRODUCTION 1
1.1 Overview 1
1.2 Components Of System 2
1.3 Advanced Technologies 2
1.4 Global Perspectives 2
2. SYSTEM ANALYSIS 3
2.1 Existing System 3
4
2.2 Drawbacks 3
2.3 Problem Definition 4
2.4 Proposed System 4
2.5 Advantages 4
3. SYSTEM REQUIREMENTS 6
3.1 Hardware Requirements 6
3.2 Software Requirements 6
3.3 Software Description 8
4. SYSTEM DESIGN 11
4.1 Module Description 12
4.2 Key Management 13
4.3 Encryption/Decryption 13
4.4 Audit And Logging 13
4.5 User Management 14
4.6 Use Case Management 14
4.7 Sequence Diagram 14
4.8 Dataflow Diagram 15
5. SYSTEM TESTING 16
5.1 Unit Testing 16
5.2 Integration Testing 16
5.3 Security And Authentication 16
5.4 Test Cases 18
5.5 Testcase I 19
5.5 Testcase II 19
6. CONCLUSION 19
APPENDICES xi
Appendix 1 – Source Code xi
Appendix 2 – Screenshots xii
REFERENCE xiv
5
LIST OF TABLES
vi
LIST OF FIGURES
vii
CHAPTER 1 INTRODUCTION
1.1 OVERVIEW
Cryptographic Key Generation for Image Encryption and Decryption focuses on
implementing secure encryption techniques to protect image data using cryptographic
keys. This Python-based application provides a graphical user interface (GUI) where
users can select an image, apply encryption using randomly generated cryptographic
keys, and decrypt the image back to its original form. The encryption algorithm
leverages a grayscale transformation of the image and utilizes a key generated through
a normal distribution, ensuring robust security. This approach to image encryption can
be beneficial in scenarios where sensitive visual data needs to be protected from
unauthorized access.
Key generation is a central aspect of this project, as the security of the encryption
process relies heavily on the strength and randomness of the keys. In this application,
the cryptographic key is dynamically generated for each encryption session, making it
highly secure and unique. The encrypted image is stored and displayed in the GUI,
allowing users to visualize the transformation from the original image to the encrypted
version and back to the decrypted form. By implementing these methods, the project
demonstrates how cryptographic techniques can be applied to image files, ensuring
confidentiality .
Additionally, the project incorporates a QR code generation feature that encodes the
image file path into a scannable format. This functionality adds another layer of data
handling, allowing the user to store or share image information securely. The project
combines the fundamentals of cryptography with practical applications like image
processing and QR code generation, offering a comprehensive exploration of modern
encryption techniques in visual data protection.
1
1.2 COMPONENTS OF SYSTEM
The Graphical User Interface (GUI) of this application is designed using Python's
Tkinter library, a popular tool for creating GUI applications. Tkinter provides an easy-
to-use interface for building the layout, buttons, and labels, making it ideal for
handling user interactions in this image encryption and decryption tool. The main
window of the application is titled "Image Encryption & Decryption" and has a
calming light blue background color (#F0F8FF), setting a visually pleasing
environment for users. This main window acts as a container for various user interface
elements, including buttons and labels, as well as for displaying the selected,
encrypted, decrypted, and QR code images .
The application features multiple buttons, each linked to specific functions that
manage different tasks. For instance, users can choose an image with the "Choose
Image" button, encrypt it with the "Encrypt" button, and decrypt it with the "Decrypt"
button. Additional buttons include options for generating a QR code of the encrypted
image, resetting the image to its original state, and exiting the application. Each button
triggers a corresponding function that performs these specific actions, ensuring that the
GUI is both interactive and functional.
This application’s image processing and encryption rely on Python's Open-CV (cv2)
library, which offers powerful tools for handling and manipulating images. Open-CV
plays a key role in reading and preparing images for encryption, including tasks like
loading the image (using cv2.imread()), resizing it to fit the interface, and converting it
to grayscale. Grayscale conversion is essential as it simplifies the data structure of the
image, making it easier to perform pixel-based encryption and decryption.
Additionally, OpenCV helps in normalizing the pixel values of the image, which scales
the data to a range suitable for mathematical operations involved in encryption.
2
QR Code Generation:
The qrcode library is used to generate a scannable QR code that represents the file path
of the selected image. This QR code provides an easy way to share the image or its
encrypted version without exposing the image data directly. When the user selects an
image, the file path is encoded into the QR code, allowing recipients to scan and access
the file’s location. This QR code is generated and displayed in the GUI, offering a
convenient sharing method while keeping the image secure. The Pillow (PIL) library
is used in tandem with this functionality to open, resize, and display the QR code
image within the application interface. Additionally, PIL handles the display of
encrypted and decrypted images, ensuring they appear at an appropriate resolution
within the GUI after processing.
File Handling:
For file handling, the application utilizes Tkinter’s filedialog module, which enables
users to open a dialog box and select an image for encryption or decryption. This
interaction provides a seamless way to retrieve the image file path, which is then used
to load the image into the system. Once the image is encrypted, it is saved locally as a
.jpg file (image_encrypted.jpg), ensuring that users have a persistent copy of the
encrypted image on disk. Similarly, the decrypted version of the image is saved as
image_output.jpg, allowing the user to easily retrieve and restore the original content.
Security Components:
The security of this application is reinforced by the Encryption Key and the QR
Code feature. A cryptographic key is generated for each encryption instance
using a random distribution method (np.random.normal()) from the Numpy
library.
3
User Interaction and Feedback:
The application includes thoughtful user interaction features, providing clear feedback
to guide the user through the encryption and decryption processes. Message boxes are
a key component for communicating with the user and are implemented using Tkinter's
mbox functions, such as mbox.showinfo(), mbox.showwarning(), and
mbox.showerror(). These message boxes notify users of various outcomes and
necessary actions. For example, when encryption or decryption is successfully
completed, an informational message box pops up to confirm the success of the
operation.
Exit Functionality:
To enhance the user experience and ensure a smooth application closure, the Exit
button allows the user to safely exit the application. When this button (labeled
exit_btn) is clicked, a confirmation prompt appears to verify that the user truly wants
to close the program. This confirmation step prevents accidental closures and allows
users to save their work or complete any last actions.
4
Advanced Encryption Techniques:
The image is normalized and encrypted by dividing pixel values by the cryptographic
key, which ensures that the original image is scrambled and cannot be easily restored
without the key. This simple but effective encryption method can be extended to more
complex cryptographic systems, such as AES (Advanced Encryption Standard) or
RSA, for stronger security.
The OpenCV (Open Source Computer Vision) library plays a vital role in real-time
image processing for this project, offering tools for efficient and effective
manipulation. OpenCV enables key operations such as converting images to grayscale,
normalizing pixel values to a scale between 0 and 1 for cryptographic readiness, and
reading and saving images in various formats. Resizing and displaying images are also
essential for presenting images clearly within the GUI, ensuring that encryption and
decryption processes maintain the visual integrity of the image.
QR code technology is integrated into this project to facilitate secure and efficient
sharing of encrypted images. Using the qrcode library, the system generates QR codes
that encode the file path of the encrypted image rather than the image data itself. This
method enhances security by ensuring that only the file path is shared, minimizing the
risk of exposing sensitive image data during the transfer process. Additionally, QR
codes offer convenience, allowing users to easily scan and access the image or its
encrypted version from their mobile devices or other systems. This makes the sharing
of images faster, more accessible, and more secure, as users can retrieve encrypted
content without the need for direct data transmission.
5
Graphical User Interface (GUI) Framework
In this project, the Graphical User Interface (GUI) is built using Tkinter, an advanced
toolkit ideal for creating cross-platform desktop applications. Tkinter is utilized for
designing interactive elements such as buttons, labels, and input forms, which facilitate
user interactions like selecting images, triggering encryption or decryption, and
generating QR codes.
The system’s intuitive interface, enabled by Tkinter, ensures that both technical and
non-technical users can operate it with ease. It also plays a crucial role in displaying
results, such as encrypted or decrypted images and QR codes. Additionally, the Pillow
(PIL) library, a powerful image processing library, is used to manage and manipulate
images within the GUI.
6
ways to protect sensitive data, and this project leverages cryptographic techniques to
ensure that images and their contents are shielded from unauthorized access.
Remote Work and Digital Communication: The rise of remote work , online
collaboration tools , and digital communication channels has led to an increased
reliance on secure data transfer systems. In this globalized era, people from different
parts of the world work and communicate digitally. The ability to securely encrypt,
decrypt, and share information (in the form of images or documents) is critical to
ensuring that sensitive data remains protected, even when transmitted over the internet.
Secure Data Sharing Across Borders: With globalization, businesses and individuals
frequently need to exchange data across national borders. This project addresses the
need for secure file sharing through encrypted images and QR codes, ensuring that
data can be shared with confidence, even between different jurisdictions.
Ease of Use: This project is designed to be accessible to users with varying levels of
technical knowledge. By incorporating user-friendly GUI frameworks (like Tkinter),
the system is intuitive and easy to navigate. This makes it accessible to a global
audience, from non-technical users who need secure image sharing for personal
purposes, to professionals and businesses that require higher levels of data protection.
7
(smartphones, tablets, etc.). This ensures the project’s functionality extends beyond
geographical boundaries and can be used by people from different cultures, regions,
and industries.
Cloud Computing for Global Scale: Cloud technology is increasingly being used
globally to scale applications, increase storage capacity, and ensure access to services
at any time from any place. By incorporating cloud-based storage and encryption
management, the project could be further developed to support global access and
scalability. This would enable users to securely store and access encrypted images, as
well as generate and scan QR codes through the cloud, providing global access and
eliminating geographical barriers.
As the world increasingly relies on distributed systems, the potential for integrating
blockchain technology becomes apparent. Blockchain can ensure that encrypted data
is securely stored and managed without reliance on centralized servers, which aligns
with the principles of data sovereignty and decentralization that are becoming more
important in global discussions about privacy and security
8
Global Cryptography Standards: Cryptographic standards and protocols such as
AES, RSA, and ECC (Elliptic Curve Cryptography) are internationally recognized and
used.
CHAPTER - 2
SYSTEM ANALYSIS
9
Fig : 2.1 Existing System Block Diagram
2.2 DRAWBACKS
Static Key Vulnerability: Many current systems use static keys for encryption, which
can be easily compromised if intercepted. Once the key is known, attackers can
decrypt any data encrypted with that key, leading to a potential security breach. There
is often no mechanism to generate dynamic keys for each session, which would
provide a higher level of security.
Limited User Control: Existing systems often offer limited flexibility when it comes
to key management and encryption techniques. Users have little to no control over the
key generation process, and the systems do not allow customization of encryption
settings based on user requirements. This can reduce the adaptability of these systems
to different security needs.
Complexity and Usability: While powerful encryption techniques such as AES and
RSA exist, they often require advanced technical knowledge to implement and
configure. Most systems lack an intuitive interface that allows non-expert users to
encrypt and decrypt image data easily. Additionally, integration of features like QR
code generation and image reset functionality is often absent, making these systems
cumbersome to use for everyday applications.
Inadequate QR Code Integration: Although QR codes can provide an efficient way
10
to store and share encrypted image data, many existing systems do not incorporate this
functionality within the encryption workflow. This lack of integration prevents users
from easily distributing encrypted images with corresponding decryption details stored
in a QR code format, limiting the usability of such systems for secure data sharing.
In today's digital world, images and multimedia data are essential forms of
communication and documentation. However, the rapid growth of the internet and
digital storage has raised serious concerns regarding the security and confidentiality
of images, especially in sensitive fields such as healthcare, law, business, and personal
privacy. As images are frequently shared over unsecure networks, there is a heightened
risk of unauthorized access, tampering, or theft of these assets.
Complexity: Many image encryption systems require extensive user input or involve
complex procedures that can be intimidating or cumbersome for non-technical users.
Performance: Some encryption methods degrade image quality after encryption and
decryption, leading to blurred or distorted images that may lose important details.
Security: Many traditional encryption techniques do not offer strong enough security
against modern cryptographic attacks. With an increasing number of hacking tools and
decryption techniques available, relying on weak encryption can make sensitive
images vulnerable to unauthorized access.
11
Sharing Issues: Secure image sharing, especially over untrusted or public channels,
remains a challenge. While encryption offers protection, sharing the encryption key
securely is often difficult. Without an efficient and secure method of key exchange, the
encryption might become ineffective.
Lack of Interoperability: Some encryption systems are designed for specific formats
or require the installation of proprietary software. This limits their ability to work
across various platforms or with different image file formats.
High-Quality Image Retention: Ensure that the image retains its original quality
(resolution, sharpness, and details) after encryption and subsequent decryption.
Scalable and Fast Operations: Ensure the encryption and decryption operations are
fast, scalable, and compatible with various image formats without significant
processing overhead.
The system will allow users to select an image, encrypt it using a randomly generated
key, and then decrypt the image using the same key. Additionally, the system will
integrate a feature for generating QR codes that store encrypted image data or file
paths, enhancing the security and ease of sharing. The user interface will be designed
to be intuitive, ensuring that users with little to no technical expertise can easily
perform image encryption and decryption operations. Moreover, the system will offer
an image reset function to restore the original image and an exit functionality for user
convenience.
2.5 ADVANTAGES
13
CHAPTER 3
SYSTEM REQUIREMENTS
The hardware and software requirements and also the platform description of the
system are explained under sections 3.1, 3.2 and 3.3 respectively.
Python 3.x: Python’s simplicity and readability make it ideal for developing GUI
applications. It also has a wide range of libraries for image manipulation and
encryption, as well as strong community support.
Key Libraries :
19
3.3 SOFTWARE DESCRIPTION
A lightweight and flexible code editor with a variety of extensions for different
programming languages and frameworks. It supports Python development with
debugging, syntax highlighting, Git integration, and more.
The extensions available for Visual Studio Code allow for customized coding
environments, with tools like code snippets, automated testing, and live server
functionality to support smooth development and testing.
Python:
A high-level, interpreted language known for its versatility, readability, and vast
ecosystem of libraries. Python’s extensive library support allows developers to
perform image manipulation, GUI creation, and even encryption with ease.
20
CHAPTER 4
SYSTEM DESIGN
The key management module handles the creation, distribution, and storage of
cryptographic keys. This module allows authorized users (like admins) to generate and
store keys securely and manage their lifecycles, including key rotation, expiry, and
revocation. By ensuring secure handling of keys, the system upholds data integrity and
confidentiality across all encryption processes.
Attribute Description
Key Generation Creates cryptographic keys with defined algorithms
Key Storage Securely stores keys in encrypted storage
Key Distribution Shares keys with authorized parties securely
Key Rotation/Revocation Manages key lifecycle including expiry and updates
21
managing cryptographic operations. This ensures data privacy by transforming
sensitive information into unreadable formats that only authorized users can decode.
Attribute Description
Encryption Uses cryptographic keys to encrypt data
Decryption Uses keys to restore data to original format
Algorithm Selection Supports various encryption algorithms (e.g., AES, RSA)
Key Usage Ensures correct key application during encryption and decryption
Audit and logging track all cryptographic activities, such as key generation,
encryption, and decryption events. This module includes maintaining records of
actions, logging errors, and creating audit trails for security monitoring. Audit logs
improve transparency and accountability by providing traceability of cryptographic
actions.
In the user management module, users can create and manage their accounts, set up
authentication methods, and manage access to cryptographic functionalities. User roles
determine permissions, with admins having more control, such as access to key
management, while regular users can only perform encryption and decryption within
allowed parameters. This module helps ensure secure access to cryptographic
resources.
Attribute Description
User Registration Allows users to register and create accounts
Authentication Verifies users' identities using secure methods
Role-Based Access Manages permissions based on user roles
Profile Update Allows users to update account details
23
4.6 USE CASE DIAGRAM
The use case diagram represents interactions between users and the cryptographic
system, illustrating key activities such as key generation, encryption, and audit
logging. Actors include Admin (for managing keys and users) and User (for
encryption and decryption actions).
Actors:
24
Database: Stores encrypted data.
25
4.8 Data Flow Diagram
26
CHAPTER 5
TESTING
27
5.3 SECURITY AND AUTHENTICATION
In any cryptographic system, security and authentication play crucial roles in
ensuring that the system is protected from unauthorized access and attacks. This
section outlines the security and authentication measures integrated into the
Image Encryption and Decryption project, with a focus on safeguarding
sensitive data and ensuring that only authorized users can interact with the system
Security Measures
Image Encryption
Viewer: Can only view the original and decrypted images but cannot perform
encryption or decryption.
28
5.4 TEST CASES
Test cases are crucial for evaluating the Home Care Service for Seniors project's
functionality, including matching seniors with healthcare providers and
coordinating services. They are essential for thorough testing, identifying issues,
and ensuring quality assurance.
The primary objective of this test case is to verify that the image encryption
functionality is working correctly. To begin, the user must first select an image from
their file system. Once the image is selected, the user clicks the "Encrypt" button. The
system should process the image, applying an encryption algorithm to the image data.
The expected outcome is that the image will be successfully encrypted and displayed
in the second panel of the application. Additionally, the encrypted image should be
saved as image_encrypted.jpg on the user's device. This test case checks that the image
encryption process happens without errors and that the encrypted image is correctly
visualized in the user interface. If the encrypted image appears in the second panel and
the file is saved properly, the test case passes. However, if the image does not display
correctly or the encryption process fails, the test case fails.
29
5.5 Image Encryption
The purpose of this test case is to ensure that the image decryption functionality works
as expected and restores the original image. After encrypting an image, the user clicks
the "Decrypt" button to initiate the decryption process. The system should use the
encryption key to decrypt the previously encrypted image, and the result should be
displayed in the second panel of the application. The decrypted image should match
the original image before encryption.The expected results include that the image
should be restored to its original form, with no loss of quality or distortion. The system
should also save the decrypted image as image_output.jpg. This test case is critical to
confirm that the encryption and decryption processes are functioning in a reversible
and accurate manner. If the decrypted image matches the original image, the test case
passes. If the image does not match or the decryption fails, the test case fails.
30
5.6 Image Decryption
CHAPTER 6
31
CONCLUSION AND FUTURE WORK
CONCLUSION
The Image Encryption and Decryption system with cryptographic key generation
serves as a secure solution for image processing by generating random keys through
Gaussian noise matrices. This approach provides a basic encryption layer, but it can
easily be extended to use more advanced cryptographic algorithms like AES or RSA.
The system's GUI, developed with Tkinter, offers a user-friendly experience where
users can select images, encrypt and decrypt them, and generate QR codes seamlessly.
Looking forward, there are multiple avenues for enhancing this system. Replacing
Gaussian noise with more robust algorithms would improve security, while adding
layered or hybrid encryption could safeguard against more complex threats. Integrating
blockchain technology could secure cryptographic keys by making them tamper-proof,
traceable, and resistant to unauthorized access. Additionally, expanding file format
compatibility to support audio, video, and other media files could transform the tool
into a versatile encryption solution.
FUTURE WORK
32
Enhanced Security Features:
The current encryption method relies on Gaussian noise, which could be improved by
implementing more robust cryptographic algorithms such as AES (Advanced
Encryption Standard) or RSA (Rivest–Shamir–Adleman) for stronger encryption and
decryption processes. Adding multiple key layers or combining symmetric and
asymmetric encryption techniques could further enhance data security.
Expanding the system to support various image and non-image file formats, including
audio and video, could make the tool more versatile. Additionally, integrating cloud
storage for key and image file management would provide greater accessibility and
security.
Large images can lead to performance issues in encryption and decryption. Optimizing
the code for speed and reducing memory usage through techniques like parallel
processing or using more efficient algorithms could improve the system's performance.
33
Real-Time Encryption:
APPENDICES
import tkinter
from tkinter import *
import tkinter as tk
import tkinter.messagebox as mbox
from tkinter import filedialog
from PIL import ImageTk, Image
import cv2
import numpy as np
import base64
import qrcode
from pyzbar.pyzbar import decode
# Defined variables
global count, emig, key, image_encrypted, original_img, panelB, panelA
34
panelA.configure(image=img)
panelB.configure(image=img)
panelA.image = img
panelB.image = img
35
qr_code_img = qr_code_img.resize((400, 400))
qr_code_img = ImageTk.PhotoImage(qr_code_img)
panelB.configure(image=qr_code_img)
panelB.image = qr_code_img
def reset():
global original_img
if original_img:
img = original_img.resize((400, 400))
img = ImageTk.PhotoImage(img)
panelB.configure(image=img)
panelB.image = img
encrypted_label = Label(window, text="Encrypted/Decrypted Image", font=("Arial",
20, "bold"), fg="#483D8B", bg='#F0F8FF')
encrypted_label.place(x=580, y=120)
window.protocol("WM_DELETE_WINDOW", exit_win)
window.mainloop
36
APPENDIX 2 – SCREENSHOTS
PLAIN IMAGE
IMPORT IMAGE
37
ENCRYPTED DATA
DECRYPTED DATA
QR CODE GENERATION
38
IMAGE RESET
39
LIST OF REFERENCES
40