Project
Project
[email protected]
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
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:
Privacy Advocates:
Individuals who are concerned about online privacy may use steganography to
hide sensitive information within images, preventing easy detection.
.
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.
n=0
m=0
z=0
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..
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.
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 :
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