0% found this document useful (0 votes)
75 views40 pages

Mini Project

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)
75 views40 pages

Mini Project

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

CRYPTOGRAPHIC KEY GENERATION

A 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

1
SUSTAINABLE DEVELOPMENT GOALS

The Sustainable Development Goals are a collection of 17 global goals designed to the
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 blueprint that they can change the world for the better.
The project is based on one of the 17 goals.

Questions Answer Samples


Data Security & Privacy
Which SDGs does the project directly address?
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
place to enhance this impact? companies to strengthen data
privacy efforts.

2
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 [Link]
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

III
TABLE OF CONTENTS

CHAPTER NO TITLE PAGE NO

ABSTRACT vi
LIST OF TABLES vii
LIST OF FIGURES viii
LIST OF ABBREVIATIONS xi

1. INTRODUCTION 1
1.1 Overview 1
1.2 Components Of System 2
1.3 Advanced Technologies 2
1.4 Global Perspectives 2
1.5 Problem Statement 2
2. SYSTEM ANALYSIS 3
2.1 Existing System 3
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

IV
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
6. CONCLUSION 19
APPENDICES xi
Appendix 1 – Source Code xi
Appendix 2 – Screenshots xii
REFERENCE xiv

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

VI
LIST OF TABLES

Table 4.2 - Key Management

Table 4.3 - Encryption / Decryption

Table 4.4 - Audit and Logging

Table 4.5 - User Management

VII
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

VIII
LIST OF ABBREVIATIONS

AES - Advanced Encryption Standard


RSA - Rivest–Shamir–Adleman (public-key encryption algorithm)
ECC - Elliptic Curve Cryptography
DES - Data Encryption Standard
3DES - Triple Data Encryption Standard
SHA - Secure Hash Algorithm
MD5 - Message Digest Algorithm 5
HMAC - Hash-Based Message Authentication Code
MAC - Message Authentication Code
PKI - Public Key Infrastructure
SSL - Secure Sockets Layer
TLS - Transport Layer Security
PGP - Pretty Good Privacy
NIST - National Institute of Standards and Technology
FIPS - Federal Information Processing Standards
ISO - International Organization for Standardization
XOR - Exclusive OR (a logical operation used in cryptography)
OTP - One-Time Pad
DH - Diffie-Hellman (key exchange protocol)
DSA - Digital Signature Algorithm
ECC - Elliptic Curve Cryptography
CTR - Counter Mode (encryption mode)
CBC - Cipher Block Chaining (encryption mode)
GCM - Galois/Counter Mode (encryption mode)
IV - Initialization Vector
KEK - Key Encryption Key
PRNG - Pseudo-Random Number Generator

IX
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 [Link]()), 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
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.

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.

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 ([Link]()) from the Numpy
library.

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 [Link](), [Link](), and
[Link](). These message boxes notify users of various outcomes and
necessary actions. For example, when encryption or decryption is successfully

3
completed, an informational message box pops up to confirm the success of the
operation.

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

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
([Link]()) 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.

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

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

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.

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.
5
1.4 GLOBAL PERSPECTIVES

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

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
6
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
(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

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.

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

8
Fig 2.1 Existing System Block Diagram

2.2 DRAWBACKS

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

2.3 PROBLEM DEFINITION

9
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. Many image encryption systems require
extensive user input or involve complex procedures that can be intimidating or
cumbersome for non-technical users. Some encryption methods degrade image quality
after encryption and decryption, leading to blurred or distorted images that may lose
important details. 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. 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. 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:

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.
10
Ensure that the image retains its original quality (resolution, sharpness, and details)
after encryption and subsequent decryption. Incorporate QR code generation to allow
users to securely share encrypted images or the encrypted image's location through a
universally accessible format. 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. 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.

Fig 2.2 Proposed system block diagram

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

12
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 :
To build the GUI, Tkinter provides tools for creating user interface elements, while
Pillow (PIL) handles image display and manipulation. OpenCV (cv2) is used for image
encryption and decryption, with NumPy supporting necessary array operations. The
qrcode library generates QR codes from image data, and pyzbar enables QR code
scanning if needed. Together, these libraries create a robust toolkit for a feature-rich,
image-focused application.

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

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 .

14
CHAPTER 4

SYSTEM DESIGN

4.1MODULE 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
managing cryptographic operations. This ensures data privacy by transforming
sensitive information into unreadable formats that only authorized users can decode.
15
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


Attribute Description

Activity Tracking Logs all encryption/decryption activities

Key Access Log Tracks access to cryptographic keys


16
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.5: 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

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

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

Database: Stores encrypted data.

18
4.7 Sequence Diagram

4.8 DATA FLOW DIAGRAM

19
4.8 Data Flow Diagram

20
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

21
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 [Link] 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 [Link] 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.

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

23
5.4 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 [Link] 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.

24
5.6 Image Decryption

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

26
APPENDICES

APPENDIX 1 - SOURCE CODE

import tkinter
from tkinter import *
import tkinter as tk
import [Link] as mbox
from tkinter import filedialog
from PIL import ImageTk, Image
import cv2
import numpy as np
import base64
import qrcode
from [Link] import decode

# Create main window


window = Tk()
[Link]("1000x700")
[Link]("Image Encryption & Decryption")

# Set a background color for the window


[Link](bg='#F0F8FF')

image_output *= 255.0 # Scale back to original pixel range


[Link]('image_output.jpg', image_output)
qr_code_img = qr_code_img.resize((400, 400))
qr_code_img = [Link](qr_code_img)
[Link](image=qr_code_img)
[Link] = qr_code_img

27
[Link]("QR Code Status", "QR Code generated successfully!")
except Exception as e:
[Link]("Error", f"An error occurred while generating the QR code:
{str(e)}")
else:
[Link]("Error", "No image selected to generate QR code!")

def reset():
global original_img
if original_img:
img = original_img.resize((400, 400))
img = [Link](img)
[Link](image=img)
[Link] = img
encrypted_label = Label(window, text="Encrypted/Decrypted Image", font=("Arial",
20, "bold"), fg="#483D8B", bg='#F0F8FF')
encrypted_label.place(x=580, y=120)
[Link]("WM_DELETE_WINDOW", exit_win)
[Link]

APPENDIX 2 – SCREENSHOTS
28
PLAIN IMAGE

IMPORT IMAGE

ENCRYPTED DATA
29
DECRYPTED DATA

LIST OF REFERENCES

30
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

31

Common questions

Powered by AI

The project addresses the limitations of traditional image encryption methods by using dynamic key generation, a user-friendly interface, and integrating QR code functionality. By avoiding static keys and providing an intuitive GUI, the project makes encryption accessible to non-experts while ensuring robust security. This contrasts with traditional methods that may use static keys and require technical expertise .

The project's encryption techniques allow for secure data sharing across borders by encrypting image data and using QR codes to share file paths securely. This approach ensures that data remains protected from unauthorized access, even when shared globally over the internet, thus addressing legal and security concerns associated with cross-border data exchange .

Integrating cloud and distributed systems into the image encryption project could enhance security by offering secure key management, increase scalability, and ensure global access to encrypted images. Cloud-based systems would facilitate easier storage and retrieval of encryption keys across multiple devices, and the use of distributed systems could leverage blockchain to further secure and decentralize data management .

The project ensures compliance with global data privacy regulations by encrypting image data, storing encryption keys securely, and utilizing QR codes for secure data sharing. These measures align with international standards, ensuring image data is protected against unauthorized access and shared in a secure manner .

The GUI design enhances user experience by being intuitive and visually pleasing with a light blue background, using user-friendly elements such as buttons for each specific action (e.g., encrypt, decrypt, generate QR code) and clear feedback through message boxes. These features make the complex encryption operations accessible to users with varying technical skills .

QR codes in this project are used to encode the file path of the selected image, allowing for secure sharing without directly exposing image data. The QR code, generated using the qrcode library, ensures that users can easily share or access the location of images or their encrypted versions, enhancing data security and accessibility .

The cryptographic key generation in the image encryption project is particularly secure because it uses dynamically generated keys for each encryption session, relying on normal distribution for randomness. This approach reduces the risk of key reuse and makes the encryption process more unpredictable and resistant to attacks .

The Pillow library is used to open, resize, and display QR code images within the application interface. It also handles the display of encrypted and decrypted images in appropriate resolutions, ensuring they fit within the GUI layout .

The project aims to solve the problem of retaining image quality post-encryption and decryption by using mathematical operations and dynamic key generation techniques that ensure images retain their resolution, sharpness, and details after being processed, as opposed to traditional methods that might degrade quality .

The use of the Open-CV library facilitates the image encryption process by providing powerful tools for handling images, such as reading the image using cv2.imread(), resizing it, and converting it to grayscale, which simplifies the data structure for encryption operations. This conversion is crucial for pixel-based encryption and decryption, making the process more efficient .

You might also like