gEncrypter PHP class - v1.0

Waht the class does - Main features

Functions in the class

gMA

function gMA()

@return mixed the array of the new alphabet

Creates a new alphabet depending on the key provided.

The process is something like the following:
Consider the key $key = "ilarvet"

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

So the conv array will be
$conv = array(
"i" => "b",
"l" => "c",
"a" => "d",
"r" => "f",
"v" => "g",
"e" => "h",
"t" => "j"
);

Then sobstitutes corresponding letters looking up for them into the conv array
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
d ? ? ? h ? ? ? b ? ? c ? ? ? ? ? f ? j ? g ? ? ? ?

Assigns the already-known chars
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
d i l a h r v e b t ? c ? ? ? ? ? f ? j ? g ? ? ? ?

Assigns to each letter its opposite in the sequence, avoiding already assigned chars
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
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

We now have a new alphabet!

gED

function gED($string, $key)

@param string $string the text to encrypt/decrypts
@param string $key the string to use to encrypt/decrypt
@return string the string encrypted/decrypted

Encrypts or decrypts datas depending on a certain key

Makes a new alphabet depending on the key provided then replaces each char in the text with its corresponding in the new alphabet.

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.

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.

Examples of use

Example #1

Takes a string, encrypts it (printing the result); then prints the string decrypted plus the key used include_once('gEncrypter.php');

$string = "Hello! You can use any char you like, but please avoid the unsupported. You can also type in UPPERCASE words!!! Incredible, huh?";

$key = "ilarvet";

$e = new gEncrypter();

echo $enc = $e->gED($string, $key); // Prints the encrypted data
echo "
";
echo $dec = $e->gED($enc, $key); // Prints the original data, decrypted
echo "
";
echo $e->key; // Prints the key used to encrypt/decrypt

Changelog

No changes made since now.

License

Copyright (C)2007 Giulio Bai

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.

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.

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

A copy of the full license can be found in the official GNU's site

Notes

Links

Plase share it!

If you found this program useful, share it! Maybe it can help also other people!
Don't be scared, it's free, editable, redistributable.
So... share, Share, SHARE!

Contacts

If you want to know more about this program, you can contact me at slide.wow@gmail.com.
Wht do you think about this program? Is it useful? How can be improved?