Skip to content

C Implementation of Pixel Value Differencing based Steganography (LSB) - PNG Cover Images

License

Notifications You must be signed in to change notification settings

mcdulltii/PVD-Steganography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Implementation of Pixel Value Differencing based Steganography

Reference: Python Implementation

LSB substitution and PVD are applied. In PVD, adaptive non-overlapping 3x3 pixel blocks or a combination of 3x3 and 2x2 blocks are used in raster fashion.

As of now extraction is done using the generated log file containing data locations using Python.

Prerequisites

  • libpng-dev (C PNG Library)
  • libmath (C Inbuilt Math Library)
  • (Optional) openmp (C Parallelization)
  • PIL (Python2/3)

Usage: Embedding

Note: Makefile uses text as input to C binary

$ echo 'Hello world!' > text
$ make (icc/strip-icc/gcc/strip-gcc/parallel-gcc/secure-gcc/all-gcc) (run) (verify)

Embedded data Log can be found in: embed.log

Usage: Extraction

Note: Makefile uses embedded.png and text as inputs below

$ python3 extract.py (Embedded_Image) (Output_File) 

extract.py uses embed.log from the same directory

Examples

Embedding and Extraction Example

Lena Example

Implementation

  1. Fractal bitmap generation

    1. The binary uses srand(time(NULL)) to choose a random fractal algorithm.
    2. Randomly generate 2 of the quartenion vector directions
    3. Use fractal algorithm to iterate bitmap pixel colours of set dimensions
  2. Check bitmap generation

    1. Anti-alias bitmap with adjacent pixels
    2. Verify bitmap is not generated entirely black
  3. Randomly choose 3x3 grids within bitmap to embed

    1. Using floored division of the bitmap dimensions, generate non-repeating (x//3, y//3) coordinates
    2. Use randomly chosen (x//3, y//3) * 3 3x3 matrix to embed bits

    Example:

    i.ii.
    1 - - ...
    - 2 - ...
    - 3 - ...
    ... ... ... ...
    1 1 1 - - - - - - ...
    1 1 1 - - - - - - ...
    1 1 1 - - - - - - ...
    - - - 2 2 2 - - - ...
    - - - 2 2 2 - - - ...
    - - - 2 2 2 - - - ...
    - - - 3 3 3 - - - ...
    - - - 3 3 3 - - - ...
    - - - 3 3 3 - - - ...
    ... ... ... ... ... ... ... ... ... ...
  4. Embed bits

    1. Classify bits to determine how much to embed
    2. Determine capacity of RGB bits can be embedded using reference to center of the 3x3 matrix
    3. Embed bits based on chosen 3x3 matrices (or 2x2 within 3x3 matrices)

    Example:

    x x x - - - - - - ...
    x x x - - - - - - ...
    x x x - - - - - - ...
    - - - x x - - - - ...
    - - - x x - - - - ...
    - - - - - - - - - ...
    - - - x x x - - - ...
    - - - x x x - - - ...
    - - - x x x - - - ...
    ... ... ... ... ... ... ... ... ... ...
  5. Log embedded bits

    1. Log variables (x, y), RGB pixel bit used, embedded length and amount of padding used, change in index of input
    2. Log variables as concatenated binary bits to reduce logging
  6. Extract embedded bits

    1. Using index of input embedded, it can determine how many bits are used for each input character
    2. Retrieve 3x3 matrix used from (x, y), or 2x2 within 3x3 matrix
    3. As some RGB pixels may have values smaller than the bits to embed, splice the embedded bits into its original length

Known issues (Might not fix due to out of scope)

  • No check for whether text string exceeds embedding capacity
  • Long text strings just below embedding capacity might get corrupted in the process

Reading Materials

About

C Implementation of Pixel Value Differencing based Steganography (LSB) - PNG Cover Images

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published