This tool will encode any message you write into the three colour channels of any image of your choosing. It will do this by altering the remainder under modular arithmetic of that channels' colour codes, in order of red, green, blue.
Encode your message into image.png
with the command python stegano.py image.png -t "this is my message."
or from a file source.txt
by using python stegano.py image.png -i source.txt
Decode such a message from encoded.png
with the command python stegano.py encoded.png -d
. If the encoded message is very long, it's recommended you pipe the result into a file with the >
operator; python stegano.py encoded.png -d > target.txt
.
This option determines how many bits of each colour of an encoded pixel are used
to store information rather than colour data. Default is -b 3
, after which the generated noise will start to be more visible, though random.
You can decide to encode the data into only every -s N
or --skipping N
.
This will of course cut the storage capacity of the image to -s 0
attempts to spread the data as evenly as possible across the image,
finding the largest skipping number that can still fit all of the data in.
-o K
or --offset K
will begin encoding the data at the
To encode
textfile.txt
intoimage.png
with bitlevel=3, skipping=15, offset=200:python stegano.py image.png -i textfile.txt -b 8 -s 15 -o 20
The program will attempt to automatically detect the message, but you can override that by using any of the flags -b, -s, -o: python stegano.py encoded.png -d -b 4 -s 3
will attempt to decode without searching for a message. Note that the automatic detection cannot find messages that use an offset, as this would increase the time-complexity of the algorithm by essentially an arbitrary factor.
With the skipping number
Example: to encode two messages, file1.txt
and file2.txt
, use
python stegano.py image.png -i file1.txt -s 2 -o 0
python stegano.py image.png -i file1.txt -s 2 -o 1
and decode using
python stegano.py encoded.png -d -s 2 -o 0
python stegano.py encoded.png -d -s 2 -o 1
usage: Steganography Tool [-h] [-i TEXTFILE] [-t MESSAGE] [-d] [-b BITS_PER_PIXEL] [-s N] [-o K] [-a] filename
Encode and decode a message into and from the colour channels of an image.
positional arguments:
filename Name of an image file.
options:
-h, --help show this help message and exit
-i TEXTFILE, --input TEXTFILE
Contents of this file will be encoded into the image.
-t MESSAGE, --type MESSAGE
Type directly to encode a message into the image file.
-d, --decode Read a message from the image file.
-b BITS_PER_PIXEL, --bitlevel BITS_PER_PIXEL
Store n bits per pixel. 1-8. Higher = more storage, less discreet, more colour data lost.
-s N, --skipping N Encode to every Nth pixel. 0 to populate the image evenly.
-o K, --offset K Start encoding at the Kth pixel, allows for multiple messages per image, assuming you use the same skipping number (>1).
-a, --analyze Tries to automatically find an encoded message and its settings.
Each pixel in the image contains three colours, red, green, and blue. Their values range from
For example: at bitlevel =
- N.B. All printable characters can be represented with 7 bits, and therefore the only functional difference between
-b 8
and-b 7
is that the former destroys more of the image.
The first
Given
Given a
bytes of storage. This way, for instance, the absolute maximum storage capacity of a 400 x 400 image is about 60kB, destroying all the colour information.
Note that compressing the image after encoding will likely destroy the encoded information as it relies on precise numerical values.
I've encoded something into the ./resources/example_encoded.png
that you can test the program on. Simply run python stegano.py example_encoded.png -d > result.txt
to see what it is.