Skip to content

Python script for encoding and decoding hidden text messages within JPEG images using LSB steganography. Encode a secret message into a JPEG, or extract a hidden message from an encoded JPEG. Requires Pillow. See README for details.

License

Notifications You must be signed in to change notification settings

BasedBadass/hiddentxt.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LSB Steganography with Python (hiddentxt.py)

This Python script provides tools for hiding and revealing secret messages within JPEG images using the Least Significant Bit (LSB) steganography technique.

Features:

  • Encode a message into a JPEG image.
  • Decode a hidden message from a JPEG image.
  • Supports basic error handling for common issues like file access.

Usage:

The script operates in two modes: encode and decode. Use the appropriate command followed by the required arguments:

Encoding:

./hiddentxt.py encode input_image.jpg "secret message" output_image.jpg

Replace the placeholders with your actual file paths and message:

  • input_image.jpg: Path to the original JPEG image to embed the message in.
  • "secret message": The message you want to hide (enclosed in quotes).
  • output_image.jpg: Path to save the modified JPEG image containing the hidden message.

Decoding:

./hiddentxt.py decode encoded_image.jpg

Replace the placeholder with the path to the encoded image (containing the hidden message).

Installation:

  1. Ensure you have Python 3 installed on your system.

  2. Install the required library using pip:

    pip install Pillow

Disclaimer:

This script provides a basic implementation of LSB steganography. It may be vulnerable to steganalysis techniques that can detect the presence of hidden messages. Consider alternative steganography methods or encryption for more secure message hiding.

Explanation:

LSB steganography manipulates the least significant bit of each color channel (red, green, blue) in the image data. This allows embedding a message with minimal visual impact on the original image.

The script performs the following steps during encoding:

  1. Converts the message to a binary string.
  2. Iterates through the image pixels and modifies the least significant bit of each color channel to embed the message bits.
  3. Saves the modified image with the hidden message.

Decoding reverses the process:

  1. Extracts the hidden message bits from the least significant bits of the image data.
  2. Converts the binary message to a readable string.
  3. Displays the decoded message.

Additional Notes:

  • The script checks for image file existence and basic error handling during image processing.
  • The message length is limited by the image size. Ensure the message can fit within the image's available bits for successful encoding.
  • Changing the output file extension (e.g., from .jpg to .png) will convert the format.

Future Improvements:

  • Implement support for different image formats (beyond JPEG).
  • Add functionalities like password protection for message decryption.

We hope this script provides a useful tool for basic LSB steganography experiments. Remember to use it responsibly and ethically.

About

Python script for encoding and decoding hidden text messages within JPEG images using LSB steganography. Encode a secret message into a JPEG, or extract a hidden message from an encoded JPEG. Requires Pillow. See README for details.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages