<h1>gEncrypter PHP class - v1.0</h1>
<h2>Waht the class does - Main features</h2>
<p>
<ul>
<li>Encrypts and decrypts text with pure PHP code using a key</li>
<li>It takes a key to generate a new alphabet that defines how the data to be encrypted should be encoded</li>
<li>ecrypts the text using the same key to revert the encrypted text</li>
<li>Supports multiple encryption with more different keys</li>
</ul>
</p>
<h2>Functions in the class</h2>
<h3>gMA</h3>
<p>
<code>
function gMA()
<br /><br />
@return mixed the array of the new alphabet<br />
</code>
<br />
Creates a new alphabet depending on the key provided.<br />
<br />
The process is something like the following:<br />
Consider the key $key = "ilarvet"<br />
<br />
The program creates an array using as indexes the chars of the key and assigns to them the first letters of the alphabet, without any double char
<br /><br />
So the conv array will be<br />
$conv = array(<br />
"i" => "b",<br />
"l" => "c",<br />
"a" => "d",<br />
"r" => "f",<br />
"v" => "g",<br />
"e" => "h",<br />
"t" => "j"<br />
);<br />
<br />
Then sobstitutes corresponding letters looking up for them into the conv array<br />
a b c d e f g h i j k l m n o p q r s t u v w x y z <br />
d ? ? ? h ? ? ? b ? ? c ? ? ? ? ? f ? j ? g ? ? ? ?<br />
<br />
Assigns the already-known chars<br />
a b c d e f g h i j k l m n o p q r s t u v w x y z <br />
d i l a h r v e b t ? c ? ? ? ? ? f ? j ? g ? ? ? ?<br />
<br />
Assigns to each letter its opposite in the sequence, avoiding already assigned chars<br />
a b c d e f g h i j k l m n o p q r s t u v w x y z<br />
d i l a h r v e b t z c y x w u s f q j p g o n m k<br />
<br />
We now have a new alphabet!<br />
</p>
<h3>gED</h3>
<p>
<code>
function gED($string, $key)
<br /><br />
@param string $string the text to encrypt/decrypts<br />
@param string $key the string to use to encrypt/decrypt<br />
@return string the string encrypted/decrypted<br />
</code>
<br />
Encrypts or decrypts datas depending on a certain key
<br /><br />
Makes a new alphabet depending on the key provided then replaces each char in the text with its corresponding in the new alphabet.
<br /><br />
Please NOTE this function encrypts AND decrypts; this mean if the text passed to it is already encrypted using this system and the same key, it will return the original one, else it will return a text encrypted two times using two DIFFERENT keys and you'll need two decryption to get the original text back.
<br /><br />
If the text passed to the method isn't ecnrypted yet, it will return the text encrypted once. The same thing happens if you use a key which match the sequence of the original alphabet.
</p>
<h2>Examples of use</h2>
<h3>Example #1</h3>
<p>
Takes a string, encrypts it (printing the result); then prints the string decrypted plus the key used
<code>
include_once('gEncrypter.php');<br />
<br />
$string = "Hello! You can use any char you like, but please avoid the unsupported. You can also type in UPPERCASE words!!! Incredible, huh?";
<br /><br />
$key = "ilarvet";
<br /><br />
$e = new gEncrypter();
<br /><br />
echo $enc = $e->gED($string, $key); // Prints the encrypted data<br />
echo "<br>";<br />
echo $dec = $e->gED($enc, $key); // Prints the original data, decrypted<br />
echo "<br>";<br />
echo $e->key; // Prints the key used to encrypt/decrypt<br />
</code>
</p>
<h2>Changelog</h2>
<p>
No changes made since now.
</p>
<h2>License</h2>
<p>
Copyright (C)2007 Giulio Bai <hide@address.com>
</p>
<p>
<blockquote>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.
<br /><br />
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
<br /><br />
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</blockquote>
</p>
<p>
A copy of the full license can be found in the <a href="http://www.gnu.org/licenses/gpl.html">official GNU's site</a>
</p>
<h2>Notes</h2>
<p>
<h3>Links</h3>
<ul>
<li><a href="http://hewle.com">http://hewle.com</a> - My site :)</li>
<li><a href="http://www.phpclasses.org">http://www.phpclasses.org</a> - Lots and lots of PHP classes</li>
<li><a href="http://www.php.net">http://www.php.net</a> - PHP official site</li>
</ul>
<h3>Plase share it!</h3>
<p>
If you found this program useful, share it! Maybe it can help also other people!<br />
Don't be scared, it's free, editable, redistributable.<br />
So... share, Share, SHARE!
</p>
<h3>Contacts</h3>
<p>
If you want to know more about this program, you can contact me at <a href="mailto:hide@address.com">hide@address.com</a>.<br />
Wht do you think about this program? Is it useful? How can be improved?
</p>
</p>