Hide Secret Messages in Images
Hide messages or other data in an image for covert distribution.
how it works
Steganography is a technique for hiding information in images. The hidden information is so subtle that for all practical purposes, it leaves the appearance of the image unchanged.
Convert the carrier image data into bytes and set the least significant bit of each to zero.
Convert the secret message into a list of bits corresponding to the ASCII serialization of the symbolic object representing the message.
Encode the length of the secret message into 48 bits and join this to the message. Then reshape the bit stream to match the shape of the image data. One bit per color channel per pixel.
Add the secret data to the carrier data and turn it back into an image. The image will look the same, but contain the secret message, and can be shared, in plain sight, with your recipient.
To decode the message, start by extracting the image data and discarding all but the least significant bit of each value.
The first 48 bits tell us how much secret data was encoded.
Excluding those 48 bits, turn the bit stream into 8-bit blocks.
For each block of bits, up to the end of the message, turn into a byte, then into an ASCII character. Finally de-serialize the character stream to a Wolfram Language expression representing the message payload.
Those steps are packaged in the functions InsertSecretMessage and ExtractSecretMessage.
You can hide entire functioning applications in images, like this interactive Manipulate of a function plot.