Monday, May 26, 2014

Steganography in GIF Images



GIF Images are very good in hiding data. It can easily hide a huge amount of data. The changes in the quality of GIF Image cannot be predicted. As it supports only 256 colors, so, generally we will be dealing with images having resolution of 1/2/4/8.

The Data to hide will be:

In 1977 and 1978, Jacob Ziv and Abraham Lempel published a pair of papers on a new class of lossless data-compression algorithms, now collectively referred to as LZ77 and LZ78. In 1983, Terry Welch developed a fast variant of LZ78 which was named Lempel–Ziv–Welch (LZW).
Working Principle
The algorithm maintains a dictionary of strings (sequences of bytes). The dictionary is initialized with one entry for each of the 256 possible byte values these are strings of length one. As the algorithm progresses it will add new strings to the dictionary such that each string is only added if a prefix one byte shorter is already in the dictionary.
LZW maintains a CODE Table to indicate a sequence of strings rather than just one at a time. First thing we do is to initialize the CODE Table. We start by adding a code for each of the default characters in the ASCII range.

Sample Image File Used:

 


O/P Image:

 




To embed in Image, two structures size & pad are used. Through size we write the DATA Size into the Image. It helps in determining the size of Data to read while Recovering Data. And through pad, we write the padding value into the Image. Through padding the Data is distributed evenly over the Image. 

While embedding data in Image, first size structure is written followed by the pad structure. And similarly, while recovering first size structure is read & then the pad structure.
 

C Code Files:

The C Code files provided in the end are:
  • ·  To Convert data from ASCII to BINARY (toBinary.c)
  • ·  To Embed Data in Image (embedGIF.c)
  • ·  To Recover Data from Image (recGIF.c)
  • ·  To Convert BINARY to ASCII (toAscii.c)
  •     Main Header File (header.h)
  •     All Required Functions (function.c)

    toBinary.c         toAscii.c           function.c           header.h           embedGIF.c           recGIF.c