Creating a Steganography Tool in Python
What is Steganography
Steganography is a method of hiding secret data in images, audio, or video. When properly done, this hidden message is not visible to the human eye and special tools must be used to reveal it. In this manner the hidden messages appear to be something else: images, articles, shopping lists, or some other cover text. The word steganography comes from the Greek word steganographia, which combines the words steganós, meaning “covered or concealed”, and -graphia meaning “writing”. The advantage of stenography is that a concealed message can not be identified as such.
The first recorded uses of steganography can be traced back to 440 BC in Greece. Histiaeus, the son of a Greek ruler, sent a message to his vassal, by shaving the head of his most trusted servant and the message onto his scalp sending him once his hair had regrown.
A Note Julias Ceaser
The Ceaser Cipher, named after Julias Ceaser, is one of the most popular early encryption techniques. It is a substitution cipher meaning that each letter in a message is replaced by a letter a fixed number of positions down the alphabet. It is often used in many other encryption techniques. As an ode to the Ceaser Cipher an image of Julias Ceaser crossing the Rubicon was used in developing this script. Julias Ceaser was known to use the Ceaser cipher in his personal correspondence.
Image Steganography
The idea behind image Steganography is very simple. Because each pixel has three data-points (representing shades of the colors red, blue and green) and each char is 8 its in length the photo that will be encoded needs to have three times as many pixels as characters in order to encode the image. Each character is converted into binary and replaces the least significant bit of each color code. We will performing this action by setting up a GUI that will help us select images, as well as hiding and retrieving there messages.
Creating Root Frame
We will first start by importing a few python libraries and creating our root frame using Tkinter. Our root frame will contain all our GUI components. The PIL library does not come by default and is used to edit images. It can be installed with the following command:
pip install pillow
We will create our root frame as follows. It will be a rectangular box with a blue background and a title.
Functionality
Our “back end” functionality will require 4 functions. We will need to open an image using the Tkinter dialog box and otherther to display it in our GUI. Two other functions will be used to hide and show messaged in the image and will rely on the segano library we will import.
Initial Frames
Next we will add a label to the GUI, which will act as a title, as well as two frames — one to hold the image and another to hold text we will using in the steno exercise. We will be adding a scrollbar to the box containing text as well. Code can be seen below:
Buttons
Third and finally we will be adding two frames containing two buttons each. Buttons will be responsible for opening, and saving stenographised images as well as showing and hiding data. This will be done by simply relying on our “back-end” functionality we created in the first section. Code will finally be executed by running:
root.mainloop()`
Code for adding buttons can be seen below:
Conclusion
Please try this out and let me know what you think. Full code can be found down below.