Hiding your name into Lover’s photo

Hiding your name into Lover’s photo

I was just browsing through PHP functions from php.net for some other purpose. I have got interested in PHP Pack function. Pack function packs data into binary string.

string pack ( string $format [, mixed $args [, mixed $… ]] )

So I thought of doing some funny things with this. I tried to hide my name into my favorite photo. Just follow the steps.

Create an upload form using html at first. Then create upload_file.php

if ($_FILES["file"]["error"] > 0)
echo "Error: " . $_FILES["file"]["error"];
echo "Upload: " . $_FILES["file"]["name"];
echo "Type: " . $_FILES["file"]["type"];
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
//Open file handle here
//read file here
//bin 2 hex conversion
$final_data = bin2hex($reading);

Now your Hexadecimal data is generated. Then add your name into $final_data string. Now we will restore the original photo from the hex value. We can hide and remove your name using
preg_match() and preg_replace() functions. Try it on your own if you want to waste some time.

$hexadecimaldata="add your hex data into the string here";
//For example I have attached a image hex value file along with the post
$picture_data = pack("H" . strlen($hexadecimaldata), $hexadecimaldata);
header("Content-Type: image/jpeg");
header("Last-Modified: " . date("r", filectime($_SERVER['SCRIPT_FILENAME'])));
header("Content-Length: " . strlen($picture_data));
echo $picture_data;

I was searching a topic related HTML5. In the mean time pack function drags me to spend one more hour in this. I have used references from w3schools.com and php.net sites. Here is the hex value of my favorite photo. Download -> Hex Value file

Leave a Reply

Your email address will not be published.