PHP Classes

BmpCrypt: Encrypt and decrypt data hidden in bitmap image

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 74%Total: 3,071 All time: 1,183 This week: 673Up
Version License Categories
bmpcrypt 1.0.0GNU General Publi...Graphics, Cryptography


BmpCrypt is a class that uses the steganography technique to hide encrypted data within a bitmap image (.BMP).

This class can hide the data very well in 24 or 32 bit RGB images.

The class could be used to hide the data in indexed color images, for instance of 256 colors, but that would require adding a few functions to deal with the modifications to the color palette.

This class implements 4 levels of bit stream encoding. Each level uses an increasing number of bits per each byte in the RGB pixel table. Therefore, the higher level of encoding will hold more bytes of data in the bitmap image.

The class comes with a Web base example that shows how to decrypt an encrypted JPEG out of a BMP file and displays the output image.

There is also an example script that shows how to use the class to encrypt and decrupt data from the command line.

Innovation Award
PHP Programming Innovation award nominee
April 2005
Number 3

Prize: One book of choice by SAMS
Some sites use digital watermark techniques to mark their images in order to notice when the images are being used without permission by other sites.

However, this does not stop people from cleaning the visible marks and still show them without asking permission or giving proper credit to the original owners. This fact makes it difficult to take legal action.

An alternative solution consists in adding information to the image files that does not show in the image itself. Later, that information could be used to detect and prove that the images files were stollen.

This class provides a solution for encrypting and embedding in image files that can be used later to demonstrate the real origin of the images.

Manuel Lemos
Picture of Chao-Chyuan Shih
Name: Chao-Chyuan Shih <contact>
Classes: 2 packages by
Country: United States United States
Age: 72
All time rank: 73496 in United States United States
Week rank: 234 Up31 in United States United States Up
Innovation award
Innovation award
Nominee: 2x


BmpCrypt Class is a very simple stenography PHP class that encodes the data in the bitmap image file. There are four levels of encoding available in this class. Level 1 - hides the data with the least-significant bit of image data bytes Level 2 - hides the data with two least-significant bits of image data bytes Level 3 - hides the data with three least-significant bits of image data bytes Level 4 - hides the data with four least-significant bits fo image data bytes Therefore, a 24-bit or 32-bit bitmap file of size 100KB is able to hide about 10 to 12KB of data with level 1 encoding, 20 to 24KB of data with level 2 encoding, 30 to 32KB of data with level 3 encoding, or 45 to 50KB of data with level 4 encoding.

  • ScreenShot.jpg
  Files folder image Files  
File Role Description
Plain text file BmpCrypt_Class.php Class BmpCrypt
Plain text file BmpCrypt_CmdLine_Example.php Example Command Line Example
Plain text file Decrypt_Webpage_Example.php Example Web Page Example
Image file Dog.bmp Photo Sample Image
Image file Horse.jpg Photo Sample Image
Image file HorseInDog.bmp Output Sample Output
Plain text file readme.txt Doc. Read Me

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:1,183
This week:673Up
 User Ratings  
 All time