You are on page 1of 25

Manju P S

manjups060@gmail.com
Jawaharlal Nehru New College of Engineering ,Shivamogga
Karnataka
Domain : Cyber Security
AICTE Student id :STU650b2eec6f21c1695231724
Duration : 13-oct-23 to 26-nov-23
Steganograph
y
Hiding Message in an Image
AGENDA
Introduction​
Project overview
​Problem Solutions and its Perception
Hiding A Message on Image
​Modelling and Results
Steganography 4

Steganography is the practice of concealing a message, file, image, or


video within another message, file, image, or video in order to hide the
existence of the concealed information.

The goal of steganography is to hide the fact that there is any


hidden information. Unlike cryptography, which focuses on making a
message secret through encryption, steganography aims to make the very
existence of the message undetectable.

Steganography is often used for legitimate purposes, such as


digital watermarking to protect intellectual property or embedding
metadata in files. However, it can also be misused for covert
communication or malicious activities. Security measures and tools are
continuously developed to detect and counteract steganographic
techniques.
There are various techniques for implementing 5

steganography, and they can be applied to different


types of media. Some common methods include:

1. Image Steganography: Concealing information within digital images by subtly modifying


the pixel values. This can involve hiding data in the least significant bits of the image, using
specific patterns, or altering the color values.
2. Audio Steganography: Embedding data within audio files by manipulating certain aspects
of the sound, such as modifying the frequency or amplitude of the audio signal.
3. Text Steganography: Concealing information within text by using techniques like hiding
messages in whitespace, changing the font or style of specific characters, or even using
invisible ink.
4. Video Steganography: Hiding data within video files by modifying certain frames or by
subtly altering the video stream.
5. Network Steganography: Concealing data within network protocols or communication
patterns.
PROJECT OVERVIEW
Hiding a text in an image

the process of hiding a text message within the pixels of an image without delving into specific code. This
explanation will cover the key concepts involved:

• Text to Binary Conversion:


The first step is to convert the text message into binary form. This is done by assigning a
unique binary code to each character in the message. Common encodings like ASCII or
Unicode are used for this purpose.
• Selecting an Image:
Choose an image to serve as the carrier for your hidden message. The image should be of
sufficient size to accommodate the binary representation of the text without visibly
altering the image.
• Pixel Modification - Least Significant Bits (LSBs):
The core of steganography involves altering the least significant bits of the pixel values in the
image. Pixels in a colored image are represented by three color channels: red, green, and blue.
Each channel has a value ranging from 0 to 255, which is represented in binary as an 8-bit
number. By modifying the least significant bit (the rightmost bit) of each channel, the change is
subtle and less likely to be noticed by the human eye.
• Embedding Binary Message:
Sequentially embed the binary representation of the text message into the LSBs of the pixel
values. This is usually done by iterating through the pixels and replacing the LSBs with the bits
from the binary message.
• Adjusting Image Metadata:
Ensure that the modifications made to the image do not significantly alter its overall appearance or
size. The goal is to make the steganographically modified image visually indistinguishable from
the original to casual observers.
• Saving the Modified Image:
Save the image with the hidden message as a new file. This file can be shared with others who are
aware of the steganographic process and know how to extract the hidden information.
• Security Considerations:
Keep in mind that this basic form of steganography is not foolproof. Certain image processing
techniques or statistical analysis may reveal the presence of hidden information. For higher
security, additional measures such as encryption before hiding the message may be employed.
WHO ARE THE END USERS of this project ?

Privacy Advocates:
Individuals who are concerned about online privacy may use steganography to
hide sensitive information within images, preventing easy detection.
.

Journalists and Whistleblowers:


•Journalists and whistleblowers may use text hiding to securely transmit confidential
information or communicate without attracting attention.

Law Enforcement and Intelligence Agencies:


•Security and intelligence professionals may use steganography for covert
communication or to embed information within images for investigative purposes.

Digital Forensics Experts:


•Professionals in digital forensics may use steganalysis techniques to detect
hidden information in images during investigations.
MY SOLUTION AND ITS VALUE PROPOSITION

Privacy and Confidential Communication:


•Value Proposition: The ability to hide text within images provides a means for individuals
to communicate confidential or sensitive information privately.
•Use Case: Whistleblowers, journalists, or individuals in need of secure communication can
use this solution to protect their messages from unauthorized access.

Covert Communication:
•Value Proposition: Steganography allows for covert communication where the presence
of a hidden message is not easily detectable.
•Use Case: Law enforcement, intelligence agencies, or individuals in sensitive situations
may use this to exchange information discreetly.

Security Measures in Cybersecurity:


•Value Proposition: In cybersecurity, steganography can be a part of
security measures to hide critical information or credentials, adding an extra
layer of protection.
•Use Case: Cybersecurity professionals may use steganography for securing
sensitive data within images to prevent unauthorized access.
Python code for hiding a Text in image
import cv2
import os
import string

img = cv2.imread("Kawasaki ZX-10RR.jpg")


msg = input("Enter secert message")
password = input("Enter password")
d={}
c={}
for i in range(255):
d[chr(i)]=i
c[i] = chr(i)
m=0
n=0
z=0
for i in range(len(msg)):
img[n,m,z] = d[msg[i]]
n=n+1
m=m+1
z=(z+1)%3
cv2.imwrite("Encryptedmsg.jpg",img)
os.system("start Encryptedmsg.jpg")
Python code for hiding a Text in image
message =""

n=0
m=0
z=0

pas = input("Enter passcode for Decryption")

if password == pas:
for i in range(len(msg)):
message = message + c[img[n,m,z]]
n=n+1
m=m+1
z=(z+1) % 3
print("Decryption message",message)
else:
print("Not valid key")
Project explanation and Modelling
1.Importing Libraries
cv2-image manipulation
os –python’s operating system
Contd…

1. secret_msg: This parameter represents the input text message that you want to convert to
hexadecimal.
2.secret_msg.encode('utf-8'): The encode method is used to convert the Unicode string
(secret_msg) into bytes using the UTF-8 encoding. This step is necessary because the hex
method operates on bytes.
3.hex(): This method is applied to the bytes obtained from the encoding. It converts each byte to
its two-digit hexadecimal representation and concatenates them. The result is a string where
each pair of characters corresponds to one byte in hexadecimal.
4.hexa_text: This variable holds the final hexadecimal representation of the input text.
5.return hexa_text: The function returns the hexadecimal representation of the input text.
Contd..

1. ‘hexa_text’:This parameter represents the input hexadecimal string that


you want to convert back to text
2. bytes.from(hexa_text): The ‘fromhex’ method is used to convert the
hexadecimal string into bytes .it reverses the processes of the ‘hex’
method .Each pair of hexadecimal charcters in the string is converted back
into a byte
3. decrypr_bytes:This variable holds the bytes obtained from the hexadecimal
string.
Contd..
4.decrypt_bytes.decode('utf-8'): The decode method is applied to the
bytes obtained from the hexadecimal string. It converts the bytes back
into a Unicode string using the UTF-8 encoding. This step is necessary
because the original text was encoded into bytes using UTF-8 before it
was converted to hexadecimal.
5.decrypted_text: This variable holds the final text representation
obtained from decoding the bytes.
6.return decrypted_text: The function returns the original text
message that was initially converted to hexadecimal.
How code works..?

Text to Binary Function:


This function takes a string text as input and converts each character in the text to
its 8-bit binary representation using the ord function and string formatting. The
resulting binary string is returned.

binary_to_text Function:
This function takes a binary message as input and converts it back to text. It does
this by iterating over the binary string in chunks of 8 bits, converting each chunk to
an integer using int(..., 2), and then converting the integer to its corresponding
ASCII character using chr. The resulting characters are joined together to form the
original text.
How code works..?

Encrypt_image Function :

This function takes the path of an image, a secret message, and a password as
inputs. It reads the image using OpenCV (cv2.imread), converts the secret
message to binary, and appends a delimiter ('1111111111111110') to mark the
end of the message.

It then iterates over each bit in the binary message and modifies the least
significant bit (LSB) of each pixel in the image to carry the binary message. The
variables n, m, and z keep track of the pixel position.

Finally, it saves the modified image with the encrypted message as


"Encryptedmsg.png" and prints a success message. The os.system("start
Encryptedmsg.png") line opens the encrypted image using the default image
viewer.
How code works..?

Decrypt_image Function :
This function takes the path of an encrypted image and a password as inputs. It
reads the encrypted image using OpenCV.

It then iterates over each pixel of the image, extracting the LSB of each color
channel to reconstruct the binary message. The loop continues until it
encounters the delimiter ('1111111111111110') that marks the end of the
message.

After extracting the binary message, it removes the delimiter and converts the
binary message to text using the binary_to_text function. The resulting
decrypted message is printed.

If the entered password does not match the provided password, it prints a
message indicating that it's not a valid passcode.
Results :

Kawasaki ZX-10RR.jpg Encryptedmsg.jpg


MODELLING
System Components:
1.User Interface (UI):
1. Description: The UI component allows users to interact with the system, providing
inputs such as the original image, secret text, and password. It also displays the output,
including the encoded image.
2. Functions:
1. Accept user inputs (original image, secret text, password).
2. Display the encoded image.
3. Provide feedback and messages to the user.
2.Text-to-Binary Converter:
1. Description: Converts the input text into binary format. This component is responsible
for encoding the secret message into a format that can be embedded in the image.
2. Functions:
1. Take the secret text as input.
2. Convert each character to its binary representation.
MODELLING
System Components:
3.Encryption Module:
1. Description: Embeds the binary message into the least significant bits (LSBs) of the image
pixels. It ensures the encoded image looks visually similar to the original.
2. Functions:
1. Take the original image, binary message, and password as inputs.
2. Embed the binary message into the LSBs of the image pixels.
3. Save the encoded image.
4.Decryption Module:
3. Description: Extracts the binary message from the LSBs of the encoded image. Converts the
binary message back to text.
4. Functions:
1. Take the encoded image and password as inputs.
2. Extract the binary message from the LSBs of the image pixels.
3. Convert the binary message back to text.
MODELLING
Considerations:
1.Encoding Process:
1. User inputs the original image, secret text, and password.
2. Text-to-Binary Converter converts the secret text to binary.
3. Encryption Module embeds the binary message in the original image, creating the
encoded image.
4. Encoded image is displayed to the user.
2.Decoding Process:
1. User inputs the encoded image and password.
2. Decryption Module extracts the binary message from the LSBs of the image pixels.
3. Text-to-Binary Converter converts the binary message back to text.
4. Decoded text is displayed to the user.
3.Optional Steganalysis:
1. If enabled, the Steganalysis Module analyzes images for potential hidden messages.
2. If steganographic content is detected, provide feedback or alerts to the user.
How did I customize the project and make it my own

1. User Interaction:
I added user prompts to input the paths, messages, and passwords, making the script interactive and user-
friendly.
2. Encryption Password:
I implemented a password (encryption key) for hiding the message in the image and a corresponding
decryption password for extracting the message. This adds a layer of security and customization.
3. Error Handling:
I have added additional error-checking mechanisms or improved the script's robustness by handling potential
issues or edge cases.
4. Security Measures:
Depending on my use case, I have implemented additional security measures, such as encryption of the entire
image or using more advanced steganography techniques.
Links:
https://github.com/manjups123/project.git

Reference

 Geeksforgeeks
 IBM skillsbuild platform
 Google
Thank you

You might also like