Home » Php » How is steganography implemented in php

How is steganography implemented in php

Posted by: admin July 12, 2020 Leave a comment


Somewhere I found out steganography .. the way of storing or hiding information within another information.. at times certain images are also used to hide the information.. Can i get an example or any thing further to know more about how this is implemented… or if at all is it possible to use this in php

How to&Answers:

You want the GD library in PHP to manipulate JPG images:

For an understanding of Steganography and Steganalysis, read this article:


Generally , if your talking about steganography, then basically you are stuffing information into the nooks and crannies of the image file. You can use nearly any image library out there as long as the image library doesn’t validate the image file strictly against a schema. You can use nearly any programming language you fancy.

There are numerous techniques. Here are some which are easy to program.

  • Use an image format which stores the
    image in chunks. You can move the
    chunks to allow gaps in the file. You
    can then hide strings of information
    in the gaps.
  • Convert the image to an indexed
    image. Declare a pallete larger than
    the number of colors. Now you can
    hide extra information in the pallete
    colors not used in the image.
  • If you are using an image format
    which has layers, you can declare a
    layer in which the alpha channel is
    maximum. This causes the layer to be
    fully transparent. You can use
    another color channel to hide your

There are numerous more techniques. Remember to use generous amounts of compression and random misleading data to make the image file look legitimate.


Here is a class from phpclasses.org for

Hide encrypted data in images using steganography

Some useful links from Steganography page at wikipedia

At last one more demo & source code over here


One common way to do steganography:

Think about a 1024 x 768, 24-bit color (i.e. 8 bits of red, 8 bits of yellow, 8 bits of blue) image. Now, the least-significant bit of the colors in the image doesn’t matter much. Therefore, one can hide three bits of information in each pixel.

That makes for 1024 * 768 * 3 / 8, or 294,912 bytes of information that can be hidden in a large image without degrading the image much.