0% found this document useful (0 votes)
16 views

Image encryption & decryption using xor

Uploaded by

Biswadeep
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Image encryption & decryption using xor

Uploaded by

Biswadeep
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

IMAGE ENCRYPTION &

DECRYPTION USING RC4


PRESENTED BY:
• RAJARSHI SAHA
• BISWADEEP PAUL
• SAPTARSHEE BANERJEE
• ARPAN KULIN
• ANIL KUMAR TURIYA
• RITTIK BOSE
CONTENT
• ACKNOWLEDGEMENT • CONCLUSION
• BIBLIOGRAPHY
• INTRODUCTION
• WHAT IS IMAGE ENCRYPTION?
• OBJECTIVE OF THE PROJECT
• XOR ENCRYPTION IN PYTHON
• SOFTWARE AND HARDWARE
REQUIREMENTS
• PROBLEM STATEMENT
• FLOWCHART
• ALGORITHM
• PSEUDO CODE
ACKNOWLEDGEMENT
We feel extremely glad in presenting our final year project at
Behala Government Polytechnic affiliated by the West Bengal State
Council of Technical Education, in the partial fulfillment of the
requirements for the diploma in Cyber Forensics & Information
Security.
We would like to specially thank to our guide Dr. Partha Sarathi
Goswami for his vigilant supervision and his constant
encouragement. Without his enthusiasm, this work could not have
been possible.
Finally, we would like to thank our parents. Without their love,
patience and support, we would be unable to complete this project.
INTRODUCTION
In today's presentation, we will
explore the concept of image
encryption and its significance in the
modern world. We will also delve into
the technical details of how image
encryption using RC4 works in Python
and its advantages and limitations.

Image encryption is a crucial aspect


of data security in various fields such
as military, healthcare, finance, and
more. With the increasing use of
digital images for communication and
storage, the need for secure image
encryption techniques has become
more important than ever before.
This is where RC4 encryption comes
WHAT IS IMAGE ENCRYPTION?
Image encryption is the process of securing digital
images by converting their pixel data into a scrambled
or encoded format using various cryptographic
techniques. The purpose of image encryption is to
protect the confidentiality and integrity of sensitive
images, preventing unauthorized access, tampering, or
eavesdropping during transmission or storage. It is a
subset of the broader field of data encryption.

The main objectives of image encryption


include:
1.Confidentiality: Ensuring that only authorized
parties can access and decipher the original image.
Even if someone intercepts the encrypted image, they
should not be able to understand its content without
the decryption key.
2.Integrity: Preventing unauthorized modification of
the image. Encryption techniques aim to make it
OBJECTIVE OF THE PROJECT
Images contain very sensitive and confidential
information. Because images play a significant
role in many applications such as military
communication, remote-sensing, and medical-
imaging, therefore, it is necessary to protect
sensitive and confidential information from
unauthorized use and modification. To achieve
this objective, encryption is one of the best
methods among the information hiding
methods. In recent years, many image
encryption approaches are designed by the
researchers. The transmission of these images
over public networks is prone to several issues
such as modification and unauthorized access.
The leakage of sensitive information may raise
military, national security, and discretionary
issues. Moreover, when individuals wish to
exchange images through a public network, it
XOR ENCRYTION IN PYTHON
XOR encryption, also known as exclusive
or encryption, is a type of encryption
that uses a bitwise operation to encrypt
data. In Python, XOR encryption can be
achieved by converting the input data
into binary format and performing the
XOR operation on each bit of the binary
data.

To demonstrate the process of image


encryption using XOR in Python, let's
consider an example where we want to
encrypt a grayscale image. First, we
read the image into Python using the
OpenCV library and convert it into a
NumPy array. Then, we convert the
NumPy array into binary format and
perform the XOR operation with a secret
SOFTWARE AND HARDWARE
REQUIREMENTS
HARDWARE REQUIRED SOFTWARE REQUIRED

• Computer: A standard desktop or • Python: You'll need Python installed


laptop computer with sufficient on your computer. Make sure to install
processing power and memory. a Python distribution like Anaconda or
use the latest Python version available
• Storage: Adequate storage space to
at the time of implementation (Python
store the images you want to encrypt
3.x).
and the Python scripts.
PROBLEM STATEMENT
In this modern world it has
been very difficult to keep
things very secure.
Technology has gone more
advance to crack things in
just a few minutes.
Through our project we
intend to solve the
problem of loss & theft of
essential data by Image
encryption. We take
chances to mitigate the
risk of Data stealing by
third parties and keeping
them for their own sake.
We try to advance in this
project as we progress
further by securing
FLOWCHART
XOR BETWEEN
START
KEYSTREAM & ARRAY

LOAD
IMAGE SAVE ENCRYPTED
IMAGE

GENERATE
KEYSTREAM
DISPLAY
ENCRYPTED
IMAGE
CONVERT INTO
ARRAY
STOP
ALGORITHM
1. Importing Libraries:
• Import the necessary modules: tkinter, PIL (Python Imaging Library), and playsound.
2. Creating the Root Window:
• Create the main application window (root) using Tk().
• Set the title, icon, dimensions, and make the window non-resizable.
3. Setting Background Image:
• Load and resize a background image using PIL.
• Create a PhotoImage object from the resized image.
• Create a Label widget to display the background image.
4. Define Button Hover Functions:
• b2_hover_enter(e): Change button colors and display a status message when the
mouse enters the button area.
• b2_hover_leave(e): Restore button colors and clear the status message when the
mouse leaves the button area.
5. Define Image Selection Function:
• select_image(): Open a file dialog to select an image file.
• Store the selected file in the file1 variable.
6. Define Image Encryption Function:
• encrypt_image(): Read the selected image file and the encryption key from the user.
• Read the image file as binary data and store it in the image variable.
• Iterate through each byte of the image data and apply bitwise XOR with the integer
value of the encryption key.
• Write the modified image data back to the original file.
• Play a sound to indicate completion and clear the encryption key input field.
7. Create Widgets:
• Create a Text widget for the user to input the encryption key.
• Create buttons (b1 and b2) for selecting an image and initiating encryption.
• Create a status label at the bottom of the window.
8. Bind Events:
• Bind functions to button hover events using <Enter> and <Leave> event handlers.
• Start the Main Event Loop:
PSEUDO CODE
# Import necessary modules

import tkinter as tk

from tkinter import *

from tkinter import filedialog

from PIL import Image, ImageTk

from playsound import playsound

# Create the Root Window

root = Tk()

# Initialize GUI settings (title, size, icon, etc.)


# Load and display background image
bg_img = LoadImage('bg.jpg')
DisplayImage(bg_img)

# Define button hover enter and leave events

def b2_hover_enter(e):
# Change button appearance and update status label

def b2_hover_leave(e):
# Restore button appearance and clear status label

# Define function to select an image file


def select_image():
# Open a file dialog to select an image file
# Store the selected file path in 'file1' global variable
# Define function to encrypt the selected image
def encrypt_image():
# Check if a file is selected
if file1 is not None:
# Get user input key
key = GetUserInputKey()
# Read image file and store the content as bytearray
image = ReadImageFile(file1)

# Encrypt each byte of the image using XOR operation with the key
EncryptImageData(image, key)

# Write the encrypted image data back to the file


WriteEncryptedImage(image, file1)

# Play a sound to indicate completion


PlayCompletionSound()

# Clear the user input key field

# Create GUI elements (buttons, labels, text fields)

# Bind button hover events to their respective functions

# Start the GUI event loop


root.mainloop()
CONCLUSION
In conclusion, we have learned about the
importance of image encryption and how it can be
achieved using XOR in Python. Image encryption is
crucial for protecting sensitive information from
unauthorized access and ensuring data privacy.
XOR encryption, in particular, offers several
advantages over other encryption methods,
including its simplicity, efficiency, and security.
By using XOR encryption in Python, we can easily
encrypt and decrypt images with just a few lines of
code. This makes it an ideal choice for developers
who want to implement image encryption in their
own projects. However, it's important to keep in
mind the limitations of XOR encryption and take
appropriate measures to ensure the security of
encrypted data.
Overall, image encryption using XOR in Python is an
exciting field with many potential applications. We
BIBLIOGRAPHY

• https://www.101computing.net/xor-encryption-algorithm/

• https://www.mdpi.com/1099-4300/23/5/535

• https://tome.app/abcd-66e5/xortify-your-images-a-pythonic-journey-into-image-en
cryption-cljgmu9ji0ni1ms3cqu9itirj

• https://chat.openai.com/

• INFORMATICS PRACTICES class 11 by Sumita Arora

• INFORMATICS PRACTICES class 12 by Sumita Arora


THANK YOU

You might also like