Hiding information in image

Enough with the boring stuff ! Today we gonna hide our super secret information in the image file 🙂 Why we might even think about it ? Well, it could be a lot of reasons, but among them is to hide sensitive information or even create invisible watermark. Nowadays a lot of companies deploy such kind of watermarks and later run algorithms to find images and claim ownership.

Let’s assume we want to hide “Hello world!” in the image. It can be done in many ways, but in our case we will represent three chars as a pixel. Our sentence has length of 12 chars long , meaning we need 4 pixels.

And short explanation is that pixel has R,G,B properties which basically represent palette consists from Red, Green and Blue colors respectively. Hence color of each pixel will consists from 3 new values stored by us. For example:

Hello world! = 72 101 108 108 111 32 87 111 114 108 100 33 (ASCII representation)

  • RGB of first pixel will be (72 101 108)
  • RGB of second pixel will be (108 111 32)
  • RGB of third pixel will be (87 111 114)
  • RGB of fifth pixel will be (108 100 33)

We will start with the simple POC (prof of concept) to introduce the idea and create very small and simple code to do so. We will use Console Application in C#.

Let’s see all code:

And then main class will create new bitmap image and store and retrieve data within/from.

By the way “Hello world” will look like following: 

The code is pretty straightforward and has comments, i believe the idea is clear enough 🙂

This post provide an idea and there improvements might be done. For example we can store our information in every N pixel. We also can use Caesar cipher or even more interesting things.

I leave it for you and for your imagination. Let me know what are you thinking about 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *