See it in action at encode.gbt.codes.
Original:
Original with Encoded Hidden Message:
Decoded Hidden Message:
- Image File
- Array
- Image File
- Text File
- Text Stream
- Text
- Array
This is best explained through an example:
Suppose the source image's bytes were 11110011 01111110 and we wanted to encode the bits 0110 into our image.
We first choose the number of least significant bits to use to encode our message. For this example, we will use 2.
The encoding process looks like this:
11110011 01111110
will transform to
11110001 01111110
Notice how we only had to change the 2 least significant bits of the first byte. In the second byte we can keep least significant bits the same because they are the same as the source message.
In order to ensure that the message is divisible by the bit split, the message may need to be padded.
To do this the padding is calculated with padding = bit_split - (number of bits in hidden message) % bit_split
. Once the value is calculated, that number of 0's is appended to the end of the message.
In order to embed the message attributes and encoding info into the image, a header is used.
The header is encoded as:
- bit split (4 bits)
- padding (4 bits)
- message length (32 bits)
- message type (2 bits)
- num extras (4 bits)
- extras (16 bits each)
Decoding is simple if the header format is known. The header tells the program what parameters to use to decode the message.
Manually Install
git clone https://github.com/GarrettBeatty/Steganography.git
cd Steganography
pip3 install -r requirements.txt
pip3 install -e .
Look at tests/test_steganography.py
for examples.
Parameters:
- --source Path to source file
- --source-type: Source type: 'image'
- --message: Image file, Text File, or String
- --message-type: Message type: 'text', 'text_file,, 'image'
- --encode: Will encode if flag is set
- --decode: Will decode if flag is set
- --bit-split: (Optional, default is 2) Number of least significant bits to use to encode message.
- --output: Output file
python3 cli.py --source <source> --encode --message <message> --bit-split <bitsplit> --output <output> --source-type <source-type> --message-type <message-type>
Example:
python3 cli.py --source images/city.jpg --encode --message images/message.jpeg --bit-split 2 --output images/encoded.png --source-type image --message-type image
python3 cli.py --source <source> --decode --output <output> --source-type <source-type>
Example:
python3 cli.py --source images/encoded.png --decode --output ~/Desktop/garrett.png --source-type image
nosetests --with-coverage --cover-package=steganography