Git Product home page Git Product logo

steg-image's Introduction

steg-image

Steganographically embed data into the color information of an image. The data is stored in the least significant bit(s) of each color channel, which can be from 1 to 8. This program makes use of the excellent stb_image.h header library. Only PNG support is enabled, because JPG encoding is lossy and corrupts the embedded data.

Compilation produces libsteg.so, which contains all the logic neccessary to encode and decode images. See steganography.h for a list of helper functions. You can include this file in your own project to take advantage of the libsteg.so library.

Example

$ ./steg-run -i my_image.png -e my_data.bin > output.png
Using 2 least-significant bits (LSB) per color channel...
Embedding "my_data.bin" into image data from "my_image.png"...
Writing resulting PNG image to stdout...
$ ./steg-run -d -i output.png > output.bin
Using 2 least-significant bits (LSB) per color channel...
Extracting embedded data from "output.png"...
Embedded data is 198072 bytes
Writing resulting data to stdout...
$ ls -1
my_data.bin
my_image.png
output.bin
output.png
steg-image
steg-run

Compiling

Things you will need:

  • gcc
  • GNU Make
  • git
$ git clone https://github.com/dseguin/steg-image
$ cd steg-image
$ git submodule update --init
$ make

Usage

USAGE: ./steg-run [-d|-e DATA_TO_EMBED] [-o OUT_FILE] [-b NUM_BITS] -i IMAGE_FILE

  -i  Use IMAGE_FILE for steganography
  -d  Decode the data embedded in IMAGE_FILE
      and send the result to stdout
  -e  Embed the file DATA_TO_EMBED into IMAGE_FILE
      and send the result to stdout
  -b  Use NUM_BITS as number of bits per color channel
      for embedded data (MIN: 1, MAX: 8, defaults to 2)
  -o  Write output to OUT_FILE (defaults to stdout)

steg-run is a convenience script that will load the libsteg.so library.

Using the -e flag, steg-image embeds the file DATA_TO_EMBED into the color data from IMAGE_FILE, and outputs the resulting PNG image to stdout (or OUT_FILE if using the -o flag). Using the -d flag, steg-image attempts to extract the data embedded in IMAGE_FILE, and outputs the resulting data to stdout (or OUT_FILE if using the -o flag). Again, this only works for PNG images currently.

The data is broken up into N-bit chunks (where 1 <= N <= 8) that are stored in reverse order in to color channels of the image, replacing the N least significant bits of each channel. This ensures the embedded data does not significantly change the image visually (if using a low number of bits). For this reason, you can only embed data up to N/8 * number_of_pixels * number_of_channels in bytes.

Assuming 2 bit chunks, the data is broken up like so:

embedded data:               01001011
                                 |
                                 v
                            01 00 10 11
                                 |
                                 v
                     11       10       00       01
image data:    11101011 10001110 01110100 00110101

The size of the embedded data is an unsigned int that is itself embedded at the start of the image data, using the first CEIL(32/N) bytes. Any form of image manipulation will corrupt the embedded data, so image hosting boards that perform image optimization will destroy anything you've embedded.

License

steg-image is released under the open source MIT license.

steg-image makes use of stb_image by Sean Barrett, which is also under the MIT license. License text for stb_image can be found here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.