# EXPERIMENT 5 – STEGANOGRAPHY

## PART A – OPENSTEGO (TEXT IN IMAGE)

1. Install OpenStego from https://www.openstego.com/.
2. Create `secret.txt` containing a message.
3. Select a cover image (`cover.jpg`).
4. Open OpenStego → Hide Data.
5. Select Message File: `secret.txt`.
6. Select Cover File: `cover.jpg`.
7. Set Output Stego File: `stego.png`.
8. Enable encryption and enter password.
9. Click Hide Data.
10. Go to Extract Data.
11. Select `stego.png` and output folder.
12. Enter password and click Extract Data.
13. Test extraction with an incorrect password.

## PART A – STEGHIDE (COMMAND LINE)

Install (Linux):
sudo apt install steghide

Hide:
steghide embed -cf cover.jpg -ef secret.txt -sf stego.jpg -p lab5pass

Check:
steghide info stego.jpg -p lab5pass

Extract:
steghide extract -sf stego.jpg -p lab5pass -xf recovered.txt

## PART B – PYTHON STEGANOGRAPHY

1. Install Python libraries:
pip install pillow numpy opencv-python

2. Create folder containing:
- cover_image.png
- secret_image.png
- cover_video.mp4

3. Create `stego_lab.py`.
4. Add encode_text() and decode_text() functions from the lab PDF.
5. Create `run_lab.py`.
6. Import functions using:
from stego_lab import *

7. Execute:
encode_text("cover_image.png", "Hello, this is a hidden message!", "encoded_image.png")
print(decode_text("encoded_image.png"))

8. Run:
python run_lab.py

9. Observe the encoded image and recovered message.

IMPORTANT: Use PNG, not JPEG, because JPEG compression destroys hidden LSB data.

## PART B3 – IMAGE INSIDE IMAGE

1. Add hide_image() and reveal_image() functions to stego_lab.py.
2. Use cover_image.png and secret_image.png.
3. Execute:

hide_image("cover_image.png", "secret_image.png", "stego_image.png", bits=4)

reveal_image("stego_image.png", "recovered_secret.png", bits=4)

4. Run:
python run_lab.py

5. Repeat using bits = 1, 2, 4 and 7.
6. Observe cover image distortion and recovered image quality.

## PART C – IMAGE INSIDE VIDEO

1. Add hide_in_video() and reveal_from_video() functions to stego_lab.py.
2. Use cover_video.mp4 and secret_image.png.
3. Execute:

hide_in_video("cover_video.mp4", "secret_image.png", "encoded_video.avi", bits=4)

reveal_from_video("encoded_video.avi", "extracted_image.png", bits=4)

4. Run:
python run_lab.py

5. Open encoded_video.avi and extracted_image.png.
6. Test lossy compression:

hide_in_video("cover_video.mp4", "secret_image.png", "lossy.mp4", bits=4, codec="mp4v")

reveal_from_video("lossy.mp4", "lossy_extracted.png", bits=4)

7. Compare recovered images.

## PART D – STEGANOGRAPHY DETECTION

1. Compare file hashes:

Windows PowerShell:
Get-FileHash cover_image.png, encoded_image.png

Linux:
sha256sum cover_image.png encoded_image.png

2. Create detective.py.
3. Add the difference-map code from the PDF.
4. Run:
python detective.py

5. Open diff_map.png.
6. Compare original and encoded image sizes.
7. Try forensic tools: steghide, exiftool, binwalk and zsteg.

## EXPERIMENT 5 – RESULT

Successfully hide and extract text/images using steganography, hide an image inside a video, and detect modifications using forensic techniques.
