Image Encoding
View the project page here.
This JavaScript steganographer allows text to be encoded into an image, without noticably changing the image. Using this, messages could be exchanged within images, in order to hide the fact that they are being sent.
The premise of this specific technique (least significant bit) changes the final bit of the red channel of each pixel in an image to encode a series of bits, representing the text. This leaves each pixel identical or almost identical to its original colour, but even to represent a 0 or odd to represent a 1. When an encoded image needs to be decoded, each bit can be extracted from its pixel using a modulo (remainder) operation.
If the text length does not perfectly fit the size of the image (which is very likely) then the code also needs to decide when to stop encoding/decoding data. In this program, this is done by encoding eight 0s in a row. In ASCII, this would represent a delete character, and is therefore very unlikely to need to be encoded as part of the text. The decoding algorithm then only has to decode up until it finds 8 consecutive 0s, at which point it determines that the message is finished.
One caveat to note is that image compression will effectively erase the message from an encoded image. When an image is (lossily) compressed, some information is discarded. This information is generally the specific pixel values, on the assumption that changing them slightly will not noticably affect the overall image. While this is fine for most situations, the least significant bit of each pixel (used to encode the binary text data) will be changed arbitrarily, resulting in the text being lost. In practice, this means that images must be saved in a non-compressing format (e.g. PNG, not JPEG) and not sent via any medium which will automatically compress them (e.g. posted to Twitter).