0% found this document useful (0 votes)
36 views37 pages

QWERT

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

QWERT

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

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

II
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


SDG 9 : 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.

II
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 SUDHA K
HEAD OF THE DEPARTMENT SUPERVISOR
Professor Assistant Professor
Computer Science and Engineering Computer Science and Engineering
Sri Krishna College of Engineering and Sri Krishna College of Engineering
Technology and Technology
Kuniyamuthur, Coimbatore–641008. Kuniyamuthur, Coimbatore–641008.

Submitted for the Project viva-voce examination held on

INTERNAL EXAMINER EXTERNAL EXAMINER

III
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. Furthermore, the application integrates a QR
code generation feature, allowing users to create QR codes of the image file path. This
feature facilitates secure and efficient data sharing, making it convenient to share
encrypted files or cryptographic keys through QR scanning.Overall, this project
demonstrates the fundamental principles of image-based cryptography, combining matrix
manipulation, noise-based key generation, and QR code functionality. It serves as a
practical and user-friendly tool for cryptographic education and application, offering
valuable insights into the integration of data science, privacy enhancement, and secure
image processing.The encryption mechanism leverages matrix manipulation techniques
by dividing the normalized grayscale pixel values of the image by the Gaussian noise-
based key matrix. This method ensures secure pixel-wise encryption, making the image
data incomprehensible without the correct cryptographic key. For decryption, the
application reverses the encryption process by multiplying the encrypted image with the
stored key matrix, accurately restoring the original pixel values and reconstructing the
image .

IV
TABLE OF CONTENTS

CHAPTER NO TITLE PAGE NO

ABSTRACT iv
LIST OF TABLES vii
LIST OF FIGURES viii
LIST OF ABBREVIATIONS ix

1. INTRODUCTION
1.1 Overview 1
1.2 Components Of System 2
1.3 Advanced Technologies 4
1.4 Global Perspectives 6
2. SYSTEM ANALYSIS
2.1 Existing System 8
2.2 Drawbacks 9
2.3 Problem Definition 9
2.4 Proposed System 11
2.5 Advantages 11
3. SYSTEM REQUIREMENTS
3.1 Software Requirements 12
3.2 Software Description 13
3.3 Summary 13
4. SYSTEM DESIGN
4.1 Module Description 14
4.2 Key Management 15
4.3 Encryption/Decryption 15
4.4 Audit And Logging 16
4.5 User Management 17
V
4.6 Use Case Management 17
4.7 Sequence Diagram 18
4.8 Dataflow Diagram 20
5. SYSTEM TESTING
5.1 Unit Testing 21
5.2 Integration Testing 21
5.3 Security And Authentication 22
6. CONCLUSION 23
APPENDICES
Appendix 1 – Source Code 24
Appendix 2 – Screenshots 26
REFERENCE 28

VI
LIST OF TABLES

Table 4.1 - Key Management


Table 4.2 - Encryption / Decryption
Table 4.3 - Audit and Logging
Table 4.4 - 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.1 – Use Case Diagram

Fig 4.2 – Sequence Diagram

Fig 4.3 – Data Flow Diagram

Fig 5.1 – Image Encryption

Fig 5.2 – 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 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
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 (np.random.normal()) 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 mbox.showinfo(), mbox.showwarning(), and
mbox.showerror(). These message boxes notify users of various outcomes and necessary
actions.

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

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.

4
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 audience,
from non-technical users who need secure image sharing for personal purposes, to
professionals and businesses that require higher levels of data protection.

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

Global Cryptography Standards: Cryptographic standards and protocols such as AES,


RSA, and ECC (Elliptic Curve Cryptography) are internationally recognized and used.

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

Fig 2.1 Existing System Block Diagram


8
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

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,

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

10
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

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.

11
CHAPTER 3

SYSTEM REQUIREMENTS

The software requirements and also the platform description of the system are

explained under sections 3.1 and 3.2 respectively.

3.1 SOFTWARE REQUIREMENTS

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.

Operating system : Windows 11

Source Code Editor : Python IDE

Coding Language : Python

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.

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

3.3 SUMMARY

In summary, the system relies on Python and associated libraries to create a flexible,
user-friendly image encryption and decryption application with a focus on modularity
and maintainability.

13
CHAPTER 4

SYSTEM DESIGN

4.1 MODULE DESCRIPTION

Key Management: This module generates and securely handles cryptographic keys,

using strong algorithms for randomness. It includes key storage and sharing options,

such as QR codes, while ensuring key rotation and expiration for enhanced security.

Encryption/Decryption Process: This core module uses mathematical operations for

pixel-wise image encryption and decryption. It manipulates grayscale image pixels

using a cryptographic key, ensuring the image data is secured during the process,

utilizing OpenCV and NumPy libraries.

User Management: Handles user login, registration, and role-based access, ensuring

only authorized users can perform encryption/decryption. User data, such as

passwords, is securely encrypted, maintaining data privacy.

Audit and Logging: Tracks all user actions, including key generation and image

processing, with secure logs for monitoring and compliance. This helps detect

unauthorized activities and supports transparent application usage.

These modules ensure secure, efficient, and user-friendly image encryption and

decryption functionality.

14
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.1: 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. The
Encryption/Decryption Process module is central to ensuring data confidentiality and
security in applications, especially in systems dealing with sensitive data such as images
or messages. This module applies cryptographic algorithms that convert readable data
(plaintext) into an unreadable format (ciphertext) using a cryptographic key

15
Table 4.2: Encryption/Decryption Process

Attribute Description

Encryption Uses cryptographic keys to encrypt data

Decryption Uses keys to restore data to original format

Algorithm
Supports various encryption algorithms (e.g., AES, RSA)
Selection

Ensures correct key application during encryption and


Key Usage
decryption

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.3: Audit and Logging

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

16
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


4.6
Authentication Verifies users' identities using secure methods

Role-Based Access Manages permissions based on user roles

Profile Update Allows users to update account details

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.5 Use case Diagram

In the Encryption/Decryption Process sequence, the User begins by selecting a file


for either encryption or decryption. The System then communicates with the Key
Management module to generate or retrieve a cryptographic key for encryption. Once
the key is received, the System proceeds with the encryption process, applying a
cryptographic algorithm to the selected file. This transforms the file into an
unreadable, encrypted format. The encrypted file is then returned to the user and stored
securely within the system.

4.7 SEQUENCE DIAGRAM: ENCRYPTION AND DECRYPTION PROCESS

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.6 Sequence Diagram

The Encryption/Decryption Process begins when the user selects a file for encryption
or decryption. The system first requests a cryptographic key from the Key
Management module. Upon receiving the key, the encryption process is initiated,
where the system applies a cryptographic algorithm to the file, turning it into an
encrypted, unreadable format. This encrypted file is returned to the user and stored
securely in the system.

19
4.8 FLOW CHART DIAGRAM

The Flow Chart Diagram for the Encryption/Decryption Process provides a visual
representation of how data moves through the system and how the various components
interact during the encryption and decryption process.

4.7 Data Flow Diagram

20
CHAPTER 5
TESTING

Fuzzing: Injects randomized input data to test the resilience of cryptographic


algorithms. Unit testing: Tests the encryption algorithm by checking edge values,
boundary values, and negative scenarios. Penetration testing: Simulates real-world
attacks to identify security weaknesses. Network sniffing: Uncovers protocol-related
vulnerabilities. Static analysis: Identifies all instances of cryptography, their purpose,
and type. Dynamic analysis: Uses method tracing to determine input and output values.

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.


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

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

23
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')

image_output *= 255.0 # Scale back to original pixel range


cv2.imwrite('image_output.jpg', image_output)
qr_code_img = qr_code_img.resize((400, 400))
qr_code_img = ImageTk.PhotoImage(qr_code_img)
panelB.configure(image=qr_code_img)
24
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

25
APPENDIX 2 – SCREENSHOTS

PLAIN IMAGE

IMPORT IMAGE

26
ENCRYPTED DATA

DECRYPTED DATA

27
WEB OF REFERENCES

1. Image Encryption and Decryption : https://www.geeksforgeeks.org/image-


encryption-and-decryption-using-python/

2. QR Code Generation in Python : https://realpython.com/

3. OpenCV for Image Processing : https://opencv-python-


tutroals.readthedocs.io/en/latest/

4. Pillow for Image Manipulation : https://pillow.readthedocs.io/en/stable/

5. Tkinter for GUI Development : https://realpython.com/

6. Pyzbar for QR Code Decoding : https://github.com/mik3y/pyzbar

28

You might also like