This is yet another follow-up post to my posts about encoding hidden messages in PNG’s: Article I, Article II.

Source code: http://pastebin.com/xWzMcayL

So far, we’ve only dealt with concealing text within PNG’s, but what about other things but text? In this post we’ll account for a method for storing arbitrary data within the least significant bits of a .PNG file.

Arbitrary data is, just like the text encoding we’ve used in the past two posts, composed of bits, so there’s no obvious reason why we shouldn’t be able to store other things than text within the least significant bits of the pixel of a .PNG file. However, data stored on the computer is composed of bytes (groups of 8 bits), and because we can store 5 bits per pixel, we can’t encode a byte into a single pixel. Instead, we choose to encode 5 bytes (40 bits) into 8 consecutive pixels (40 bits), which fits neatly. So, to store a file within a .PNG file, we’ll read it as bytes, and split these into groups of 5 bytes. Then we’ll “jump” (as explained in Article II) accordingly, and store these 5 bytes within the next 8 pixels. We’ll add 5 blank bytes (0x00) at the end of our data as an “exit code” – otherwise the program will read random bytes indefinitely.

We’ve used this to encode an image onto one of theses images of Barack Obama:

Hint: The password is ‘realobama’

The program is not limited, however, by images. You can encode literally any byte-string unto the least significant bits of an image. This includes .txt-files, .zip-files and even executables (!). So if you want to send a secret file within an image, this is the program for you!

The source code is found at the top of this post. Note: You need the Group-class found in Article II for the program to work properly.

Future plans: This program is easily susceptible to deciphering – even without knowing the passphrase. I might construct a decoder eventually.

Here’s how to use it with the new features:

//Encoding Encoder e = new Encoder("path-of-image-file.png"); e.encodeFile("path-of-file-to-encode", "password"); e.saveFile("new-embedded-image.png"); //Again, we encourage .PNG //Decoding Encoder e = new Encoder("path-of-image-file.png"); e.saveContentFile("path-of-extracted-file", "password");