How To Hide Data in Images Using Python

Learn the art of Image Steganography

Ashwin Goel
Better Programming

Steganography is the art of hiding secret data in any file.

The secret data can be data of any format like text or even a file. In a nutshell, the main motive of steganography is to hide the intended information within any file, usually an image, audio, or video, without actually changing the external appearance of the file, i.e. it should look the same as before.

In this blog, we will be focussing on learning image-based steganography, i.e. hiding secret data in an image.

But before diving a little deeper into it, let’s look at what an image comprises of.

  1. Pixels are the building blocks of an image.
  2. Every pixel contains three values: (red, green, blue) also known as RGB values.
  3. Every RGB value ranges from 0 to 255.

This much information is enough to get started.

Now, let’s look at how we can encode and decode data into our image.

Encoding

There are a lot of algorithms that can be used to encode data into the image, and in fact, you can also make one yourself. The one being used in this blog is easy to understand and implement, as well.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (3)

What are your thoughts?

It dosen't work for me it says "TypeError: 'int' object is not subscriptable"

--

odd

I think it should be even.

--

Hi,
If some pix values are 0s, what will happen in your code?

--