0% found this document useful (0 votes)
6 views2 pages

Steganography Project

This document outlines a guide for implementing a Steganography-based data hiding system using Python, focusing on hiding and extracting data in images via the Least Significant Bit (LSB) method. It includes detailed steps and example code for both hiding a secret message within an image and extracting it from a stego image. The project demonstrates a basic technique for concealing and retrieving messages in digital images.

Uploaded by

ddark6924
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)
6 views2 pages

Steganography Project

This document outlines a guide for implementing a Steganography-based data hiding system using Python, focusing on hiding and extracting data in images via the Least Significant Bit (LSB) method. It includes detailed steps and example code for both hiding a secret message within an image and extracting it from a stego image. The project demonstrates a basic technique for concealing and retrieving messages in digital images.

Uploaded by

ddark6924
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/ 2

Steganography-Based Data Hiding System

This document provides a step-by-step guide to implementing a Steganography-based data hiding


system using Python. We will cover both the hiding and extraction of data in images using the LSB
method.

1. Project Overview
Steganography is the technique of hiding secret information within a file (e.g., image, audio) so that
it remains undetectable. This project focuses on hiding text within an image using the Least
Significant Bit (LSB) method.

2. Steps to Implement
The implementation consists of two main parts:
1. Hiding the secret message inside an image.
2. Extracting the hidden message from the stego image.

3. Hiding Data in an Image


The following Python code hides a secret message inside an image by modifying the least
significant bits of the pixel values.

from PIL import Image

def hide_data(image_path, secret_message, output_path):


image = Image.open(image_path)
binary_message = ''.join(format(ord(char), '08b') for char in secret_message) +
'00000000'
pixel_list = list(image.getdata())

new_pixels = []
binary_index = 0

for pixel in pixel_list:


new_pixel = list(pixel)
for i in range(3):
if binary_index < len(binary_message):
new_pixel[i] = (new_pixel[i] & ~1) | int(binary_message[binary_index])
binary_index += 1
new_pixels.append(tuple(new_pixel))
image.putdata(new_pixels)
image.save(output_path)
print("Data hidden successfully in", output_path)

# Example Usage
hide_data("input_image.png", "Hello, this is secret!", "stego_image.png")

4. Extracting Hidden Data from an Image


The following Python code extracts the hidden message from the stego image.

from PIL import Image

def extract_data(image_path):
image = Image.open(image_path)
binary_data = ""

for pixel in image.getdata():


for color in pixel[:3]:
binary_data += str(color & 1)

message = ""
for i in range(0, len(binary_data), 8):
byte = binary_data[i:i+8]
if byte == "00000000":
break
message += chr(int(byte, 2))

return message

# Example Usage
secret_message = extract_data("stego_image.png")
print("Hidden Message:", secret_message)

5. Conclusion
This project successfully implements a basic steganography technique for hiding and extracting
secret messages from images using the Least Significant Bit (LSB) method.

You might also like