Steganography: the art of hiding in plain sight. Messages specifically. These are a series of tools that aid in embedding messages in digital files.
While steganography provides obscurity, it does not strictly provide security. Before hiding your message using any of these scripts, it's suggested you encode your message (try PGP/GnuPG encryption or put it in a TrueCrypt container if you're at a loss).
The PNG file format divides the image data into 'chunks', and allows for additional, private chunks to be added by image editors. This script takes the message you wish to embed and saves it as binary data in such an ancillary chunk.
The files being embedded are compressed with bzip2
compression if they're not already a bzip2
archive. This is different from the deflate
compression used in the rest of the PNG file format, but gives better compression. Run pngload.py --help
for usage information.
8-bit image files encode color data in red, green, and blue values from 0-255 (0x00 to 0xFF) each. This script uses the lower 4 bits of each color channel to save a separate binary message. Thus every two pixels can store three bytes worth of data (0xRG, 0xBR, 0xGB), and each pixel's color channel get shifted at max ± 16 of 255. The script adds a four-byte header on the front of the binary data, which indicates its length. The output has to be a PNG file, since JPEG compressing can ruin the lower bits, and palette-based images (PNG8 or GIF) don't have enough color options for this purpose.
Future enhancements: If the image is large enough and the message is small enough, the script could use less bits/channel to store the message (4 = 3 bytes/2 pixels, 2 = 3 bytes/4 pixels or 1 = 3 bytes/8 pixels). This would produce less visible color shift in the image overall, but would take up more of the image. In addition, being able to define a rectangle in the image where the message is stored would allow the user to pick a more noisy area of the image to make it less noticeable that the colors have been messed with.