A hobby project to learn the Rust language. This project uses steganography: it encodes a message inside the color/alpha channels of a PNG image's pixels, then later decodes the message to a terminal window.
To encode an image, build and run with:
[width] [height] [decode password] [.txt file with the message] [file name for the PNG]
Be sure to save the final password from the terminal. This is needed to decode the message.
Encoding has two steps. The first step encodes the message characters in their numeric (u8) form inside the color/alpha channels of an intermediate PNG that has been filled with random noise. The noise is there to make it harder to determine which pixels and which channels hold the message information - the only way to know which ones count is to have the password, which sets up the decoding pattern. The intermediate PNG:
The second step converts the channel values of every pixel in the intermediate image into binary, splits the binary values into individual digits, then applies them to a "mask" file, or an ordinary-looking image. If a binary digit is 0, then one of the channels of the corresponding mask pixel is adjusted (if needed) to hold an even value. If 1, then odd. The visual changes to the image are very slight and usually imperceptible in images with a large variety of bold colors. For example:
To decode, much the same:
[decode password] [PNG's file name]