Skip to content

sobhanlori/steganography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Steganography

A lightweight PHP package for hiding and retrieving secret messages inside PNG images using steganography.

Features

  • Hide text messages inside images
  • Extract hidden messages from encoded images
  • Simple and fluent API
  • No external dependencies required

Installation

Install the package via Composer:

composer require sobhanlori/steganography

Requirements

  • PHP 8.1+
  • GD extension enabled

Usage

Hide Data Inside an Image

<?php

use Sobhanlori\Steganography\Steganography;

$steganography = new Steganography();

$steganography
    ->conceal('example.png', 'This is hidden text!')
    ->save('example-secret.png');

Download Encoded Image

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;

How It Works

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.

Limitations

Image Format

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.

Supported Characters

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

Example

<?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 Message

Contributing

Contributions are welcome.

Running Tests

composer test

Before submitting a pull request, please ensure all tests pass successfully.

Security Notes

Steganography hides the existence of data but does not encrypt it.

For sensitive information, consider encrypting your message before embedding it into an image.

License

The MIT License (MIT).

See the LICENSE file for more information.

About

A lightweight PHP package for hiding and retrieving secret messages inside PNG images using steganography

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages