0% found this document useful (0 votes)
38 views42 pages

Mini

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views42 pages

Mini

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 42

CRYPTOGRAPHIC KEY GENERATION

A MINI PROJECT REPORT


Submitted by

GAYATHRI S (727722EUCS050),
HAASHINI A (727722EUCS060),
GURURAGAVENDRA PS (727723EUCS501),
HEMANTH SURYA AS (727723EUCS503)

in partial fulfilment for the award of the

degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE AND ENGINEERING

SRI KRISHNA COLLEGE OF ENGINEERING AND TECHNOLOGY

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.

Questions Answer Samples


Which SDGs does the project directly address? Data Security & Privacy Enhancement
Image Encryption, Decryption
What strategies or actions are being
Techniques, QR Code for Secure
implemented to achieve these goals?
Sharing
How is progress measured and reported in Encryption Quality, Decryption
relation to the SDGs? Accuracy, User Feedback
These goals align with the project’s
How were these goals identified as relevant to focus on innovative data protection,
the project’s objectives? user security, and secure information
sharing.
We aim to collaborate with
Are there any partnerships or collaborations in
cybersecurity firms and tech companies
place to enhance this impact?
to strengthen data privacy efforts.
BONAFIDE CERTIFICATE

Certified that this project report titled “CRYPTOGRAPHIC KEY GENERATION” is


the Bonafide work of HAASHINI A (727722EUCS060), HEMANTH SURYA AS
(727723EUCS503), GAYATHRI S (727722EUCS050), GURURAGAVENDRA PS
(727723EUCS501) who carried out the project work under my supervision.

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.

Submitted for the Project viva-voce examination held on

INTERNAL EXAMINER EXTERNAL EXAMINER


ABSTRACT

This project implements a graphical application for image encryption and


decryption with cryptographic key generation, utilizing Python's tkinter GUI library
and OpenCV for image processing. The application allows users to select an image,
generate a random cryptographic key, and perform encryption and decryption on the
selected image. The encryption is based on dividing the normalized grayscale pixel
values of the image by a Gaussian noise-based key matrix, ensuring secure pixel-wise
encryption . The decryption reverses this process by multiplying the encrypted image
with the stored key, restoring the original pixel values. Additionally, the application
provides the ability to generate QR codes of the file path, facilitating easy data sharing.
This project demonstrates the fundamental principles of image-based encryption and
decryption using matrix manipulation, providing a practical, user-friendly interface for
cryptographic learning and application.

TABLE OF CONTENTS

CHAPTER NO TITLE PAGE NO

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

Table 4.2 - Key Management

Table 4.3 - Encryption / Decryption

Table 4.4 - Audit and Logging

Table 4.5 - User Management

vi
LIST OF FIGURES

Fig 2.1 – Existing System Block Diagram

Fig 2.2 – Proposed System Block Diagram

Fig 3.1 – VS Code Logo

Fig 4.6 – Use Case Diagram

Fig 4.7 – Sequence Diagram

Fig 4.8 – Data Flow Diagram

Fig 5.5 – Image Encryption

Fig 5.5 – Image Decryption

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

Graphical User Interface (GUI):

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.

Image Processing and Encryption Components:

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.

1.3 ADVANCED TECHNOLOGIES

Cryptography for Image Encryption and Decryption

Cryptographic Key Generation: The project uses random number generation


techniques to create a cryptographic key that encrypts and decrypts images.
Specifically, the project leverages the Gaussian (Normal) distribution
(np.random.normal()) to generate a key that is unique for each image. This ensures that
even if two images are identical, their encrypted versions will be different due to
unique encryption keys. Such techniques form the foundation of secure communication
and data protection in modern cryptography.

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.

Image Processing and Computer Vision

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 Generation for Secure Sharing

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.

Cloud and Distributed Systems Integration (Future Scope)

As the project progresses, there is a significant potential to integrate cloud and


distributed systems to enhance both the security and scalability of the image
encryption and sharing process. Cloud-based key management can offer a more secure
environment for storing cryptographic keys, ensuring that they are protected and
accessible from multiple devices.

1.4 GLOBAL PERSPECTIVES

Data Privacy and Security Concerns

Global Increase in Cybercrime: As the world becomes more digitized, there is an


escalating risk of cyber threats. Hackers, identity theft, and data breaches are some of
the most pressing concerns faced globally. Encryption is one of the most effective

6
ways to protect sensitive data, and this project leverages cryptographic techniques to
ensure that images and their contents are shielded from unauthorized access.

Regulations and Compliance: Different countries have established stringent data


privacy laws and regulations . This project’s approach to data encryption and secure
sharing aligns with such regulations by ensuring that image data can be encrypted,
safely stored, and shared in compliance with global privacy standards.

Digital Transformation and Global Connectivity

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.

Access to Technology and Inclusivity

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.

International Applicability: The use of QR codes is especially useful on a global scale,


as they are widely recognized and compatible across multiple devices and platforms

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 Integration and Scalability

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.

Distributed Systems and Blockchain

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

International Adoption of Cryptographic Solutions

Adoption in Global Enterprises: Large-scale enterprises across the world, especially


those in sectors such as finance, healthcare, and government, are increasingly adopting
advanced cryptographic solutions to protect sensitive data. The demand for end-to-end
encryption and secure file sharing systems is growing as these organizations deal with
large volumes of confidential information. This project, with its image encryption and
decryption capabilities, could be extended to meet the security needs of international
businesses, offering them a secure and efficient solution for data protection.

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

2.1 EXISTING SYSTEM

In the current landscape of image encryption and decryption systems, various


techniques are utilized to protect image data from unauthorized access. Traditional
methods often involve simple password-based protection or basic encryption
algorithms like the XOR cipher. Additionally, some systems employ symmetric
encryption techniques such as AES (Advanced Encryption Standard) or DES (Data
Encryption Standard), where the same key is used for both encryption and decryption.

The use of QR codes in image security systems is another emerging feature, as QR


codes can store information related to image paths or encryption details. However,
most existing systems treat QR code generation as a standalone feature rather than
integrating it within the encryption and decryption workflow. Moreover, while there
are systems that allow for basic image encryption, the process often requires complex
configurations or specialized knowledge to implement effectively, which can make
them less user-friendly.

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.

2.3 PROBLEM DEFINITION

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.

While encryption is a well-established technique to secure textual data, the encryption


of images presents unique challenges. Unlike text, which can be encoded into a simple
string format, images are complex data structures consisting of pixels with color
values, which makes applying conventional encryption methods difficult. Furthermore,
there are issues related to image size, format compatibility, and maintaining image
quality post-encryption and decryption.

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.

Specifically, the project aims to solve the following key problems:

Secure Encryption of Images: Implement a cryptographic solution that is simple to


use and highly secure, ensuring that images cannot be accessed or tampered with
without the correct decryption key.

High-Quality Image Retention: Ensure that the image retains its original quality
(resolution, sharpness, and details) after encryption and subsequent decryption.

Efficient Sharing: Incorporate QR code generation to allow users to securely share


encrypted images or the encrypted image's location through a universally accessible
format.

Scalable and Fast Operations: Ensure the encryption and decryption operations are
fast, scalable, and compatible with various image formats without significant
processing overhead.

2.4 PROPOSED SYSTEM

The proposed system focuses on developing a robust Cryptographic Key Generation


System for Image Encryption and Decryption that ensures secure image data protection
12
by dynamically generating cryptographic keys for each session.

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.

Fig : 2.2 Proposed system block diagram

2.5 ADVANTAGES

Enhanced data security through image encryption.


Easy decryption of images to restore original content.
User-friendly interface for non-technical users.
QR code generation for secure image sharing.

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.

3.1 HARDWARE REQUIREMENTS


Processor Type : Ryzen i5
RAM : 8GB RAM
Hard Disk : 512GB

3.2 SOFTWARE REQUIREMENTS

Operating system : Windows 11

Front End, Back End : Visual studio code

Coding Language : Python

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 :

tkinter: For building the graphical user interface.


Pillow (PIL): For image display and manipulation.
OpenCV (cv2): Core library for image encryption and decryption.
NumPy: Supports array operations needed for encryption.
qrcode: To generate QR codes from image data.
pyzbar: For decoding QR codes (if QR scanning functionality is added).

19
3.3 SOFTWARE DESCRIPTION

Visual Studio Code:

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.

Object-Oriented and Modular: The project is structured around object-oriented


principles and modular functions for ease of maintenance and scalability .

20
CHAPTER 4
SYSTEM DESIGN

4.1 MODULE DESCRIPTION


Key Management
Encryption/Decryption Process
User Management
Audit and Logging

4.2 KEY MANAGEMENT

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.

Table 4.2: Key Management

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

4.3 ENCRYPTION/DECRYPTION PROCESS

This module is responsible for applying cryptographic algorithms to data using


generated keys. It includes specifying the type of encryption (e.g., symmetric or
asymmetric), handling encryption/decryption of files or messages, and securely

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

Table 4.3: Encryption/Decryption Process

4.4 AUDIT AND LOGGING

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.

Table 4.4: Audit and Logging


22
Attribute Description

Activity Tracking Logs all encryption/decryption activities

Key Access Log Tracks access to cryptographic keys

Error Handling Logs errors or anomalies in cryptographic processes

Audit Trail Provides a detailed record for security audits

4.5 USER MANAGEMENT

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.

Table 4.4: User Management

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).

4.6 Use case Diagram

4.7 SEQUENCE DIAGRAM: ENCRYPTION AND DECRYPTION PROCESS

Actors:

User: The individual requesting encryption or decryption.

Application Interface: The user interface of the application.

Encryption Service: The service that performs encryption and decryption.

24
Database: Stores encrypted data.

4.7 Sequence Diagram

4.8 DATA FLOW DIAGRAM

25
4.8 Data Flow Diagram

26
CHAPTER 5
TESTING

5.1 UNIT TESTING


Unit testing is a crucial part of the software development process, ensuring that
each individual component or function of the system operates as intended.
Below are some key unit tests for the Image Encryption and Decryption project
based on the provided code:

Test 1: openfilename Function

Test 2: open_img Function

Test 3: en_fun Function (Image Encryption)

Test 4: de_fun Function (Image Decryption)

Test 5: generate_qr_code Function.

5.2 INTEGRATION TESTING


Integration testing focuses on ensuring that different components of the system
work together as expected. This testing phase is essential to identify issues
related to the interaction between various modules or functions

Test 1: Integration of Image Selection and Encryption

Test 2: Integration of Image Decryption after Encryption

Test 3: Integration of QR Code Generation and Image Selection

Test 4: Integration of Reset Functionality

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

The project utilizes a symmetric encryption technique to encrypt and decrypt


images. The image is first converted to a grayscale format and then encrypted using a
randomly generated key based on a normal distribution. This ensures that the
encryption is not easily predictable.The image encryption is done using mathematical
operations (such as division by a random key) that make it computationally difficult to
reverse the encryption without the correct key.The key used for encryption is
generated dynamically each time the encryption process is initiated, which makes it
more secure by reducing the risk of key reuse.

Role-Based Access Control (RBAC)

In the case of a multi-user system, implementing role-based access control (RBAC)


could be essential. Users can be assigned different roles (e.g., Admin, User, Viewer)
with varying levels of permissions. For example:

Admin: Can upload images, encrypt, decrypt, and generate QR codes.

User: Can only view encrypted images and generate QR codes.

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.

5.4.1 TEST CASE I

Test Case I: Image Encryption

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

5.4.2 TEST CASE II

Test Case II: Image Decryption

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.

Performance optimizations would be beneficial, especially for handling large images,


which can slow down the system. Implementing parallel processing or more efficient
algorithms could reduce memory usage and speed up the encryption and decryption
processes. Finally, enabling real-time encryption for video streams or images from live
camera feeds would open new use cases, such as secure surveillance, live data
protection, and secure data sharing in real-time applications.

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.

Integration of Blockchain Technology:

To improve data integrity and authentication, blockchain can be used to store


cryptographic keys securely, ensuring that the keys used in encryption are tamper-
proof and traceable.

File Format Support:

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.

Optimization for Performance:

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.

User Authentication and Role-Based Access:

Implementing a user authentication system to control access to the encryption tool


would be a useful addition, especially in corporate or multi-user environments. Role-
based access can ensure that only authorized users can perform encryption or
decryption tasks.

33
Real-Time Encryption:

In future iterations, enabling real-time encryption of video streams or images captured


via a camera could open up new use cases in live data protection.

APPENDICES

APPENDIX 1 - SOURCE CODE

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

# Create main window


window = Tk()
window.geometry("1000x700")
window.title("Image Encryption & Decryption")

# Set a background color for the window


window.configure(bg='#F0F8FF')

# 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

# Function for encrypting the image


def en_fun():
global x, image_encrypted, key
image_input = cv2.imread(x, 0) # Read image in grayscale
image_input = image_input.astype(float) / 255.0 # Normalize the image

# Generate encryption key


key = np.random.normal(0, 0.1, image_input.shape)
image_encrypted = image_input / key

cv2.imwrite('image_encrypted.jpg', image_encrypted * 255)


imge = Image.open('image_encrypted.jpg')
imge = imge.resize((400, 400))
imge = ImageTk.PhotoImage(imge)
panelB.configure(image=imge)
panelB.image = imge
mbox.showinfo("Encrypt Status", "Image encrypted successfully.")

# Function for decrypting the image


def de_fun():
global image_encrypted, key
image_output = image_encrypted * key
image_output *= 255.0 # Scale back to original pixel range
cv2.imwrite('image_output.jpg', image_output)

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

mbox.showinfo("QR Code Status", "QR Code generated successfully!")


except Exception as e:
mbox.showerror("Error", f"An error occurred while generating the QR code:
{str(e)}")
else:
mbox.showwarning("Error", "No image selected to generate QR code!")

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

1. "Cryptography and Network Security: Principles and Practice" by William


Stallings
2. "Python for Data Analysis" by Wes McKinney
3. "Python Machine Learning" by Sebastian Raschka and Vahid Mirjalili
4. "Learning OpenCV 4: Computer Vision with Python" by Joseph Howse,
Prateek Joshi, and Michael Beyeler
5. "Tkinter GUI Application Development Blueprints" by Bhaskar Chaudhary
6. "QR Codes: The Ultimate Guide" by Johannes G. Langer
7. "Practical Cryptography in Python" by Seth James Nielson and Christopher
K. Monson

40

You might also like