In the world, all people are divided into two types:
some want something to
hide ,
others want the opposite, something to
find . Today we will be on the side of the first. We will hide.
On how to hide files in the system, many probably already know. But how to hide the text in the files, but so that it would not be visible, few know. And so begin.
We will hide plain text from the “txt” file. And we will record it in mp3 files. Many people know that there are tags in mp3 files. But hardly anyone thought what their length is and what can be done with them. Wikipedia
says tag length
equals 30 characters. There is also a
Comment tag, but we will not touch it.
Tags can be changed using special programs. Such as for example
Mp3Tag .
What and where we will write to understand. Now we decide on what we will write. For these purposes, I chose
PHP and
PEAR package MP3_Id . To this set we need to add a virtual server,
Denwer or
XAMPP or some other. As you like.
Our tool will consist of two scripts, one of which will record and the other will read MP3 tags respectively.
First you need to install the module PEAR MP3_Id:
- Start Menu-> Run-> CMD
- Go to the directory where the php interpreter is installed -> pear install MP3_Id
Let's start the analysis of scripts.
')
Script number one. read.php
Below will be listed and analyzed the functions used in this script.
We need a function that counts the number of lines of 30 characters in the file.
function CalcSize($f) // 30 { $size = 0;
A function that reads data of 30 characters from a file into an array.
function ReadDataFiles($size) { $arr = array(); $f = fopen('data.txt','rb'); for($i = 0; $i < $size; $i++) { $arr[$i] = fread($f, 30);
Functions for working with tags.
Reading:
function ReadTags($file) { echo $file.' '; $mp3 = &new MP3_Id(); $result = $mp3->read($file); echo $mp3->getTag('name'); echo $mp3->getTag('artists'); echo $mp3->getTag('album'); }
Record:
function SetTags($file, $data1,$data2,$data3) { $mp3 = &new MP3_Id(); $result = $mp3->read($file); $mp3->setTag('name', $data1); $mp3->setTag('artists', $data2); $mp3->setTag('album', $data3); $result = $mp3->write(); }
We also need to create arbitrary file names. We will just take one source and copy it.
function GenerateName() { $abc = array('q','w','e','r','t','y', 'u','i','o','p','a','s', 'd','f','g','h','j','k', 'l','z','x','c','v','b', 'n','m','1','2','3','4', '5','6','7','8','9','0'); $name=""; for($i = 0; $i < 8; $i++) { $index = rand(0, count($abc) - 1); $name .= $abc[$index]; } return $name; }
And so we have all the necessary functions. You can make the structure of the script.
We connect the newly installed module.
require_once 'MP3/Id.php';
$fileSize = CalcSize();
And here is the function that hides the text in the tags. It is fed to the input: an array with strings, and the number of rows.
function HideData($arr, $number) { $numberMp3Files = floor($number / 3) + 1;
This is the whole script for writing text in the tags of mp3 files. I want to add that the MP3 file for copying is desirable to take a small size. And call it file.mp3.
It remains to write a script that will return us all back. From mp3 tags to text file.
Script number two. write.php
Again we connect the PEAR module
require_once 'MP3/Id.php';
Create a file for writing.
$handle = fopen("new_data.txt","w");
Already familiar to us function for reading tags. Slightly changed.
function ReadTags($file, $fo) { $mp3 = &new MP3_Id(); $result = $mp3->read($file); $name = $mp3->getTag('name'); $srtists = $mp3->getTag('artists'); $album = $mp3->getTag('album'); fputs($fo, "$name"); fputs($fo,"$artists"); fputs($fo, "$album"); }
Go to the directory with the files.
chdir('files');
create a list of MP3 files
$list = glob('*.mp3');
Sort it
sort($list);
And for each file we call ReadTags function.
foreach($list as $a) { ReadTags($a, $handle); }
How to work with PEAR MP3_Id is better to look at offsite. I can hardly explain clearly. During the experiments it was revealed that if the source file has some tags, then in windows the created files have the same tags. But at the same time, our information is recorded and readable in them. And if there are no tags, then ours are written, which are perfectly visible in the explorer. So it is better to use a file with tags, and then everything will definitely be super secret.
If you find any errors, or know how to improve the script, be sure to write. I would be glad. For errors in the design of the post, I apologize, he is the first.