PHP Classes
elePHPant
Icontem

PHP Steganography Kit: Library of algorithms to encode messages in images

Recommend this page to a friend!
  Info   View files View files (44)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2014-11-18 (2 years ago) RSS 2.0 feedStarStarStarStar 76%Total: 435 This week: 5All time: 6,023 This week: 160Up
Version License PHP version Categories
steganography-kit 1.0.0BSD License5.4Algorithms, PHP 5, Graphics, Cryptogr...
Description Author

This package is a library of algorithms to encode messages in images.

It can take a given message and hides it inside a given image file so it is not perceptible.

The package implements several algorithms to hide and recover the text in the images using the least significant bit: pure steganography and secret key steganography.

The package can hide text or binary data in images in the PNG, JPEG and GIF formats with custom channels set.

The channels order can be used as a secret key for pure steganography. The secret steganography can also randomly choose the pixels or the channels it uses to make the algorithm more secure.

Recommendations

use steganography in php
hide and retrieve data in image

What is the best PHP image steganography class?
Hide user names and passwords inside images with steganography

  Performance   Level  
Name: Sergii Pryz <contact>
Classes: 9 packages by
Country: Ukraine Ukraine
Innovation award
Innovation award
Nominee: 4x

Details

SteganographyKit

Latest Stable Version License Build Status Coverage Status SensioLabsInsight

SteganographyKit is a package with implementation several algorithms for image Steganography.

Steganography is the art and science of hiding information by embedding messages within other, seemingly harmless messages [1]. General overview of Steganography can be found in [3], [7]. SteganographyKit is used terminology described by Christian Cachin [1].

SteganographyKit contains:

  • Least Significant Bit (LSB) * Pure Steganography * Secret Key Steganography

Requirements

  • PHP 5.4+
  • GDLib
  • ZLib
  • Only for Suhosin patch special configuration should be added: ` suhosin.srand.ignore = Off suhosin.mt_srand.ignore = Off `

Installation

The best way to install SteganographyKit is use composer:

  • Update your composer.json
{
    "require": {
        "picamator/steganographykit": "dev-master"
    }
}

  • Run composer update

Usage

Encode

<?php

require __DIR__ . '/vendor/autoload.php';

$stegoContainer = new Picamator\SteganographyKit\StegoContainer();

// cover-image.png|.jpg|.gif - path to existing image to cover secretText
// stego-image.png  - path where new stegoImage should be saved
$stegoContainer->encode('/path/to/cover-image.png', 
    '/path/to/stego-image.png', 'secret test');

// output raw image 
$stegoContainer->renderImage();

Decode

<?php

require __DIR__ . '/vendor/autoload.php';

$stegoContainer = new Picamator\SteganographyKit\StegoContainer();

// stego-image.png
$secretText = $stegoContainer->decode('/path/to/stego-image.png');

echo $secretText;

Use other stegoSystem

<?php

require __DIR__ . '/vendor/autoload.php';

$stegoContainer = new Picamator\SteganographyKit\StegoContainer();
$stegoSystem    = new Picamator\SteganographyKit\StegoSystem\SecretLsb();

// configure secret key
$secretKey = 123456;
$stegoKey  = new Picamator\SteganographyKit\StegoKey\RandomKey($secretKey);

$stegoSystem->setStegoKey($stegoKey);
$stegoContainer->setStegoSystem($stegoSystem);

// it's not necessary to set second parameter if result will put in stream 
$stegoContainer->encode('/path/to/cover-image.png', '', 'secret test');

// output raw image
header('Content-Type: image/png');
$stegoContainer->renderImage();

Least Significant Bit (LSB)

LSB method is modified least significant bit of coverText to get stegoText. Detailed description with example can be found in [4] or in "Steganography in Depth" section [5].

SteganographyKit has implementation of LSB with such conditions: * png, jpg or gif images as coverText, * text as a secretText.

Pure Steganography

Pure Steganography is a Steganography system that doesn't require prior exchange of some secret information before sending message [2].

Additionally it's possible to configurate channels that will be used in algorithm. For instance secretText can use only Red or Green and Blue or Red, Green, Blue. Moreover order in witch channels are used is important. So channels can be interpreted as Secret Key.

Note: Some researches use only Blue channel for steganography because that color is less perceived by human eye. Such conclusion is based on experiment [6]. But it should be taken critically because first of all stegoanalyze use computer technique to identify picture with hidden information, the second digital picture is displayed on a screen that has enough light.

Secret Key Steganography

For Secret Key Steganography is similar with Pure Steganography but Secret Key is used for encode-decode process [2].

SteganographyKit is used approach described in [2], accordingly them Secret Key is a seed for pseudo-random generator [8]. Such seed is used to create sequences of coordinates of coverText's pixels for covering secretText.

SteganogrpahyKit implements Secret Key Steganography with such conditions: * SecretKey has limit: from 4 to 8 numbers. It uses as a seed for mt_srand function.

Encode/Decode algorithm is differ from Pure Steganography by: * Method of choosing pixels in CoverText. In Pure Steganography it gets one by one but in Secret Key Steganography gets accordingly pseudo-random algorithm. * Method of use RGB channels. In Pure Steganography order is the same as user set but for Secret Key Steganography is changes accordingly pixel's coordinates.

If pixel coordinates X and Y and array of channels is ['red', 'green', 'blue'] then 'red' will have (X + Y) % 3 index in channel array the channel that had (X + Y) % 3 would be moved to old red's place. For instance X = 4, Y = 10 them (2 + 10) % 3 = 2 then new channels array is ['blue', 'green', 'red']. So using such approach secretText will be randomly spread through coverText bits but also through channels.

UML Diagram

UML diagrams can be found in /doc/uml folder:

  • Class diagram was created by ArgoUML
  • Workflow diagram was written by Google Drawing

License

BSD-3-Clause

References

  1. Christian Cachin "Digital Steganography". IBM Research, 17 February 2005, https://www.zurich.ibm.com/~cca/papers/encyc.pdf
  2. Zaidoon Kh. AL-Ani, A.A.Zaidan, B.B.Zaidan and Hamdan.O.Alanaz "Overview: Main Fundamentals for Steganography"// Journal of computing, vol. 2, issue 3, March 2010 http://arxiv.org/pdf/1003.4086.pdf
  3. Sean-Philip Oriyano "Using steganography to avoid observation Hiding in plain sight." IBM Research, 02 June 2009, http://www.ibm.com/developerworks/web/library/wa-steganalysis/index.html?ca=dat
  4. Vijay Kumar Sharma, Vishal Shrivastava "A steganography algorithm for hiding image in image by improved lsb substitution by minimize detection" // Journal of Theoretical and Applied Information Technology, vol. 36 issue 1, 15th February 2012 http://www.jatit.org/volumes/Vol36No1/1Vol36No1.pdf
  5. Gregory Kipper "Investigator's Guide to Steganography", CRC Press, Oct 27, 2003, 240 pages http://books.google.com.ua/books?id=qGcum1ZWkiYC&pg=PA37&source=gbs_toc_r&cad=3#v=onepage&q&f=false
  6. Seling Hecht, Simon Shlaer, Maurice Henri Pirenne "Energy, quanta and vision"// JGP vol.25 no. 6, 819-840, July 20, 1942 http://rieke-server.physiol.washington.edu/People/Fred/Classes/532/Hecht1942.pdf
  7. Ali K. Hmood, B.B. Zaidan, A.A. Zaidan and Hamid A. Jalab "An Overview on Hidden Information Technique in Images"// Journal of Applied Science vol.10, issue 18, pages 2094-2100, 2010 http://scialert.net/abstract/?doi=jas.2010.2094.2100
  8. Craig Buckler "How to Create Your Own Random Number Generator in PHP", February 8, 2012 http://www.sitepoint.com/php-random-number-generator/
  Files folder image Files  
File Role Description
Files folder imagedoc (1 directory)
Files folder imagesrc (1 directory)
Files folder imagetest (1 directory)
Accessible without login Plain text file CHANGELOG.md Data Documentation
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  doc  
File Role Description
Files folder imageuml (2 files)

  Files folder image Files  /  doc  /  uml  
File Role Description
  Accessible without login Image file class.diagram.png Data Auxiliary data
  Accessible without login Image file lsb-encode-decode.png Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imagePicamator (1 directory)

  Files folder image Files  /  src  /  Picamator  
File Role Description
Files folder imageSteganographyKit (4 files, 6 directories)

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  
File Role Description
Files folder imageImage (2 files)
Files folder imageIterator (3 files)
Files folder imageOptions (1 file)
Files folder imageSecretText (3 files)
Files folder imageStegoKey (3 files)
Files folder imageStegoSystem (4 files)
  Plain text file InvalidArgumentException.php Class Class source
  Plain text file LogicException.php Class Class source
  Plain text file RuntimeException.php Class Class source
  Plain text file StegoContainer.php Class Class source

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  /  Image  
File Role Description
  Plain text file Image.php Class Class source
  Plain text file ImageInterface.php Class Class source

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  /  Iterator  
File Role Description
  Plain text file ImageIterator.php Class Class source
  Plain text file ImageRandomIterator.php Class Class source
  Plain text file SecretTextIterator.php Class Class source

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  /  Options  
File Role Description
  Plain text file OptionsTrait.php Class Class source

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  /  SecretText  
File Role Description
  Plain text file AbstractSecretText.php Class Class source
  Plain text file PlainText.php Class Class source
  Plain text file SecretTextInterface.php Class Class source

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  /  StegoKey  
File Role Description
  Plain text file AbstractStegoKey.php Class Class source
  Plain text file RandomKey.php Class Class source
  Plain text file StegoKeyInterface.php Class Class source

  Files folder image Files  /  src  /  Picamator  /  SteganographyKit  /  StegoSystem  
File Role Description
  Plain text file AbstractLsb.php Class Class source
  Plain text file PureLsb.php Class Class source
  Plain text file SecretLsb.php Class Class source
  Plain text file StegoSystemInterface.php Class Class source

  Files folder image Files  /  test  
File Role Description
Files folder imagePicamator (1 directory)

  Files folder image Files  /  test  /  Picamator  
File Role Description
Files folder imageSteganographyKit (2 files, 6 directories)

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  
File Role Description
Files folder imagedata (4 files, 1 directory)
Files folder imageImage (1 file)
Files folder imageIterator (3 files)
Files folder imageSecretText (1 file)
Files folder imageStegoKey (1 file)
Files folder imageStegoSystem (3 files)
  Accessible without login Plain text file BaseTest.php Test Class source
  Accessible without login Plain text file StegoContainerTest.php Test Class source

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  data  
File Role Description
Files folder imagelsb (1 directory)
  Accessible without login Image file original_200_200.png Data Auxiliary data
  Accessible without login Image file original_50_50.png Data Auxiliary data
  Accessible without login Plain text file README.md Data Documentation
  Accessible without login Plain text file secret_text.txt Data Auxiliary data

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  data  /  lsb  
File Role Description
Files folder imagepure (2 files)

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  data  /  lsb  /  pure  
File Role Description
  Accessible without login Image file lorem_ipsum_li_200_200.png Output Sample output
  Accessible without login Image file stego_origin_200_200.png Output Sample output

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  Image  
File Role Description
  Accessible without login Plain text file ImageTest.php Test Unit test script

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  Iterator  
File Role Description
  Accessible without login Plain text file ImageIteratorTest.php Test Unit test script
  Accessible without login Plain text file ImageRandomIteratorTest.php Test Unit test script
  Accessible without login Plain text file SecretTextIteratorTest.php Test Unit test script

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  SecretText  
File Role Description
  Accessible without login Plain text file PlainTextTest.php Test Unit test script

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  StegoKey  
File Role Description
  Accessible without login Plain text file RandomKeyTest.php Test Unit test script

  Files folder image Files  /  test  /  Picamator  /  SteganographyKit  /  StegoSystem  
File Role Description
  Accessible without login Plain text file BaseLsbTest.php Test Unit test script
  Accessible without login Plain text file PureLsbTest.php Test Unit test script
  Accessible without login Plain text file SecretLsbTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:435
This week:5
All time:6,023
This week:160Up
User Ratings User Comments (1)
 All time
Utility:95%StarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:-
Tests:100%StarStarStarStarStarStar
Videos:-
Overall:76%StarStarStarStar
Rank:79
 
Works fine - thanks!
2 years ago (Andreas Schmidt)
80%StarStarStarStarStar