CYB322 Course Project 101
CYB322 Course Project 101
The word Steganography is derived from two Greek words- ‘stegos’ meaning ‘to
an audio, video, image, or text file. It is one of the methods employed to protect secret
Cryptography and steganography are both methods used to hide or protect secret data.
However, they differ in the respect that cryptography makes the data unreadable, or
hides the meaning of the data, while steganography hides the existence of the data.
people can read it but won’t understand what it means. However, the existence of a
(probably secret) message would be obvious to anyone who sees the letter, and if
someone either knows or figures out your secret language, then your message can
easily be read.
If you were to use steganography in the same situation, you would hide the letter
inside a pair of socks that you would be gifting to the intended recipient of the letter.
To those who don’t know about the message, it would look like there was nothing
more to your gift than the socks. But the intended recipient knows what to look for,
3
Similarly, if two users exchanged media files over the internet, it would be more
difficult to determine whether these files contain hidden messages than if they were
Cryptography algorithms are used to encrypt secret data before embedding it into
cover files.
Image Steganography:
As the name suggests, Image Steganography refers to the process of hiding data
within an image file. The image selected for this purpose is called the cover
image and the image obtained after steganography is called the stego image.
How is it done?
An image is represented as an N*M (in case of grayscale images) or N*M*3 (in case
of color images) matrix in memory, with each entry representing the intensity value
the values of some pixels, which are chosen by an encryption algorithm. The recipient
of the image must be aware of the same algorithm in order to know which pixels he
4
Figure1: Process of Image Steganography
His steganography approach entails concealing a huge amount of data (picture, audio,
and text) within a color bitmap (bmp) image. The image will be filtered and
segmented in his study, with bits replacement applied to the appropriate pixels. These
Detection of the message within the cover image is done by the process
of steganalysis. This can be done through comparison with the cover image,
histogram plotting, or noise detection. While efforts are being invested in developing
new algorithms with a greater degree of immunity against such attacks, efforts are
also being devoted towards improving existing algorithms for steganalysis, to detect
terminal.
5
I. Run the following command to install the ‘PIL' library:
Storing and communicating secret and/or private information has become part of our
daily life whether it is for our employment or personal well-being. Therefore, secure
storage and transmission of the secret information have received the undivided
attention to many.
the greatest way to disguise a message from adversaries while still protecting it in
case it is detected.
6
SECTION 2: STEGANOGRAPHY IN THEORY
In theory Image method is the practice of hiding information by using the cover item as the
image. Images are a popular cover source in digital steganography because the digital
representation of a picture contains many bits. There are several methods for concealing
Least Significant Bit (LSB) is one of the most popular techniques used.
To understand how LSB works, first we need to know how a pixel works.
1- A pixel color is defined by 3 channels: Red, Green, Blue, also known as RGB.
Each channel can have a value in a range between 0 and 255. The higher the value of a channel,
You can use any combination of those channels to generate the color you want.
Binary. Each channel of a pixel needs 1 byte, which means, 8 bits, that is, 8 1s and 0s. For
7
It will result in a blue pixel, but if we change the value of the blue channel from 255 to 254:
We just change a single bit of the pixel, the last one (the Least Significant Bit).
The two blue colors are similar. Even if they’re joined, we won’t be able to see the difference:
We can make this change on the 3 channels; it means that we can store 3 bits per pixel and the
2- ASCII Table
To encode the message, we get the respective decimal value from the ASCII table. If we want to
encode a single letter “a”, the decimal value for this letter according to the table is 97, in
binary: 01100001. How we can store 3 bits per pixel, only changing the last bit, we’ll need 3
pixels to encode the ‘a’ in our image. The first pixel will store 0 1 1, on the last bits of each
RGB channel, the second will store 0 0 0, and the third will store 0 1 (the blue channel will not
be needed for this one). Joining the last bits of these pixels we’ll have: 01100001, converting
this binary to decimal will result in 97, which is “a” according to the ASCII table.
8
Figure2: QR code as an Image.
In this illustration, QR code represents the cover file such as image, and it shows that binary bits
are modified using LSB technique it modifies the last bit of each byte to embed or hide one bit
of the file. If the attacker wants to hide one megabyte of a file using this method, they need an
image of eight megabytes in size. With this technique, it’s difficult to compare the original picture to
the modified one. It also changes the last bit of each of those bytes to hide one bit of data. So, to hide
one megabyte of data using this method, you’ll need an eight-megabyte image file. Since changing the
last bit of the pixel value doesn’t change the picture enough to be seen, a person looking at the original
picture and the modified picture won’t be able to tell the difference.
Our program represents the LSB Algorithm as the appropriate technique to our project.
9
SECTION 3: IMPLEMENTATION
#import modules
from tkinter import *
import tkinter.filedialog
from tkinter import messagebox
from PIL import ImageTk
from PIL import Image
from io import BytesIO
import os
class IMG_Stegno:
output_image_size = 0
#Main frame
def main(self, root):
root.title('ImageSteganography')
root.geometry('600x700')
root.resizable(width =True, height=True)
root.config(bg = '#f0f0f0')
frame = Frame(root)
frame.grid()
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
10
F2 = Frame(root)
label1= Label(F2,text='\n\n\n\n\nSelect any image to type\nan encrypted message\n')
label1.config(font=('Times new roman',23, 'bold'),bg = '#f0f0f0')
label1.grid()
11
e_pg.grid(row=1)
e_F2.destroy()
while (True):
pixels = [value for value in image_data.__next__()[:3] +
image_data.__next__()[:3] +
image_data.__next__()[:3]]
binary_str = ''
for i in pixels[:8]:
if i % 2 == 0:
binary_str += '0'
else:
binary_str += '1'
12
for i in data:
new_data.append(format(ord(i), '08b'))
return new_data
if (i == dataLen - 1):
if (pix[-1] % 2 == 0):
pix[-1] -= 1
else:
if (pix[-1] % 2 != 0):
pix[-1] -= 1
pix = tuple(pix)
yield pix[0:3]
yield pix[3:6]
yield pix[6:9]
13
newImg.save(tkinter.filedialog.asksaveasfilename(initialfile=temp,filetypes = ([('png',
'*.png')]),defaultextension=".png"))
self.d_image_size = my_file.tell()
self.d_image_w,self.d_image_h = newImg.size
messagebox.showinfo("SUCCESS!!!","MESSAGE ENCRYPTED SUCCESSFULLY\n")
def frame_3(self,frame):
frame.destroy()
self.main(root)
#GUI loop
root = Tk()
o = IMG_Stegno()
o.main(root)
root.mainloop()
First, we called all the important modules from the library to implement all used functions in the
program. Then we set up a main frame by defining (main) function with objects including
frames, encryption, and decryption.
We then defined encryption as the encryption method to encrypt the texts into the images. And
the decryption method to decrypt the texts out of the images.
We also made a Function to modify the pixels of an image.
The output of the program is that you have the choice to either encrypt or decrypt any image you
want:
Encryption:
1. Choose any image you want in any type.
2. Type any text you want to encrypt.
3. Click on the encrypt button.
4. Rename the image to differentiate
5. Send the picture to the desired person.
Decryption:
1. Click on the renamed image.
2. Click on the decrypt button.
3. The text will appear below the image.
4. Click on the cancel button to head back to the main frame.
14
SECTION 4: EXPERIMENTAL RESULTS
15
SECTION 5: EXPLANATION AND DISCUSSION OF THE RESULTS
Program Performance:
• The program performed very well during execution due to the encryption method used
and the programmed functions.
Program Strength:
• The strength point is the LSB Method, it was a great choice to illustrate how a text can be
emerged into an image to look like nothing happened.
Program Difficulties:
• The difficulties were when we tried to configure pixels of images and blend the text
inside, we then settled on extracting 3 pixels at a time to ease the way.
16
SECTION 6: CONCLUSION
In conclusion, image steganography is a vital tool for ensuring data privacy and security in
today's digital world. This comprehensive guide has provided insights into the different types
and techniques of this practice, ranging from spatial to compressed domain steganography.
The LSB technique, PVD technique, spread spectrum technique, and randomized embedding
technique were also explored in-depth. Steganography will continue to be essential in protecting
sensitive information from hackers as technology develops at an unparalleled rate.
It is observed that through LSB Substitution Steganographic method, the results obtained in data
hiding are pretty impressive as it utilizes the simple fact that any image could be broken up to
individual bit-planes each consisting of different levels of information. It is to be noted that as
discussed earlier, this method is only effective for bitmap images as these involve lossless
compression techniques.
17