Veröffentlicht aminCTFAufrufe: Symbole im Artikel gezählt: 1k WörterLesezeit ≈1 min
LSB-Steganography is a technique in which we hide messages inside an image by replacing Least Significant Bit (LSB) of an image with the bits of messages to be hidden.
The Least Significant Bit (LSB) is the lowest bit of a binary number. For example, in the binary number 10010010, “0”is the least significant bit (as shown in the image above).
By modifying only the first most right bit of an image, we can insert our secret message almost unnoticeably, but if our message is too large, we will need to start modifying the second rightmost bit and so on.
Implementation in Python
We only need one module —— the PIL module. We first use the constLenBin() function to transform the strings of characters to binaries, making sure that the length is always 8. Then we use the encodeDataInImage() function to encode the binaries into images.
The decodeImage() is to return the hidden texts after the image is being decoded, and the binaryToString() function converts the binaries to strings of characters. If the code in the function binaryToString() seems confusing, please read about UTF-8 and code points here.