A lightweight PHP package for hiding and retrieving secret messages inside PNG images using steganography.
- Hide text messages inside images
- Extract hidden messages from encoded images
- Simple and fluent API
- No external dependencies required
Install the package via Composer:
composer require sobhanlori/steganography- PHP 8.1+
- GD extension enabled
<?php
use Sobhanlori\Steganography\Steganography;
$steganography = new Steganography();
$steganography
->conceal('example.png', 'This is hidden text!')
->save('example-secret.png');If you're using the package in a web application, you can directly send the generated image to the browser:
<?php
use Sobhanlori\Steganography\Steganography;
$steganography = new Steganography();
$steganography
->conceal('example.png', 'This is hidden text!')
->download('example-secret.png');Retrieve Hidden Data
<?php
use Sobhanlori\Steganography\Steganography;
$steganography = new Steganography();
$data = $steganography->reveal('example-secret.png');
echo $data;The package uses image steganography techniques to embed data within image pixels. The visual appearance of the image remains nearly identical to the original while containing hidden information that can later be extracted.
Currently, all generated output images are saved as PNG files.
$steganography
->conceal('image.png', 'Secret Message')
->save('output.png');Using PNG ensures that hidden data is preserved because PNG is a lossless image format.
At the moment, hidden messages can contain:
- English alphabet characters (
A-Z,a-z) - Numbers (
0-9) - Common symbols and punctuation
Unicode and non-English characters are not currently supported.
Examples of supported text:
Hello World!
User123
[email@example.com]
Secret Message #1
<?php
require 'vendor/autoload.php';
use Sobhanlori\Steganography\Steganography;
$steganography = new Steganography();
// Hide data
$steganography
->conceal('photo.png', 'My Secret Message')
->save('photo-secret.png');
// Reveal data
$message = $steganography->reveal('photo-secret.png');
echo $message; // My Secret MessageContributions are welcome.
composer testBefore submitting a pull request, please ensure all tests pass successfully.
Steganography hides the existence of data but does not encrypt it.
For sensitive information, consider encrypting your message before embedding it into an image.
The MIT License (MIT).
See the LICENSE file for more information.