Image Encryption

The trouble with encrypting documents is that its quite obvious that they have been encrypted which makes people want to decrypt them.

So what about some kind of sexy algorithm that encodes a message within a picture? If the picture only gets slightly changed, then no one will ever realise it contains a secret message, since it looks to all intents and purposes like its a genuine picture.

So, an evenings hacking later and I’ve come up with an algorithm that does it. The program takes an image file (gif, jpeg, etc) and outputs a bitmap (it cannot be output to a format that compresses with loss like JPEG, otherwise its not possible to decrypt the message since what gets saved is saved with bits lost).

Here is an example of a red image that has been modified to contain a message:

OK, if you look close (see below which is zoomed in) you can see the modified dots. But its just an example.

So here is a photo that has been modified to contain a different secret message:

Again, without zooming in, its hard to see the changes. Below is a zoomed in version. You can see the changes as speckled dots.

The algorithm has been tuned to try and match the changes to the pixels around the changed pixel. If the surrounding area is blue, the change will be blue, whereas if the area around the change is red, the result will be a red pixel. You should be able to see this quite easily. One thing I found was that its not so good if the image contains lots of white or black. The algorithm prefers red/green/blue images.

So if we use a standard photo editing program and add some noise (uniform, 20% in the following case), you really cannot see the changes that the algorithm has made. It simply looks like a badly taken picture.

It’s even better if you use some kind of effect on the image:

During encryption I provide a pass phrase that is used to encrypt the message. The text is encrypted before being inserted into the image, so effectively it has been doubly encrypted. There is also a parameter that is used to specify how close together each changed pixel is, so that either all changes are to a single region, or all changes are spread out throughout the image.

In these examples only about a thousandth of the original image has been changed. With rough images, there would be no problem changing several percent of the image. But what is sure is that the resulting image (as in the encrypted hidden file) would be 20, 40 or even 100 times as large as the file or message being encrypted.

Practical Applications
The best application is simply put, file encryption, hiding the input within an image so its harder to find by prying eyes. The above example shows how text messages have been encrypted, but there is no reason this cannot be extended to files. How about a Web Service or Web Application that anyone could use to encrypt their secrets? Potentially coming up soon…

I’m quite sure this has been done before, but I just wondered how easy it would be… and at first glance, it seems not that hard.

If you’re interested in its use, contact me.

And as enticement to crack this algorithm, how about 100 english pounds to the first person to email me the message that’s encrypted in the speckled version of the picture of the clouds?

**** UPDATE ****

Apparently this is called steganography and is a well researched field! That just proves you how hard it is to invent anything new. Anyway, I have optimised the algorithm and build a website dedicated to it: