Your IP: 38.107.179.218
PHP Encode and Decode Function
Posted by: Asif D. Khalyani
User Can download php function for Encode & DecodeThe PHP Encoder allows to encode PHP scripts before distributing it. The script code saving with use cryptography. Because PHP Encoder based on PHP source this software working on ALL computer and server platforms which support PHP. The PHP Encoder includes converter for encryption/decryption of your scripts. You can use wildcards for easy converting of their projects. The PHP Encoder is transparent to your visitors. It is possible to combine protected and unprotected scripts in one site.
<?php
// Encode function starts here
function encode($_text, $_IV = 3, $_ENCRYPT_KEY = "z1Mc6KRxA7Nw90dGjY5qLXhtrPgJOfeCaUmHvQT3yW8nDsI2VkEpiS4blFoBuZ")
{
if (is_numeric($_IV)) {
$_IV = intval($_IV);
if ($_IV < 1)
$_IV = 1;
else
if ($_IV > 500)
$_IV = 42;
} else {
$_IV = 3;
}
$_text .= ' ';
$_arr1 = stringSplit($_ENCRYPT_KEY);
$_arr2 = $_arr1;
foreach ($_arr1 as $_i1 => $_v1) {
foreach ($_arr2 as $_i2 => $_v2) {
$_counter = ($_i2 + 1) + ($_i1 * strlen($_ENCRYPT_KEY));
$_array[$_counter] = $_v1 . $_v2;
if ($_v1 == $_v2)
$_array[$_counter] = $_v1 . '_';
}
}
$_encoded = '';
$_count = 0;
$_msgarr = stringSplit($_text);
foreach ($_msgarr as $_mindex => $_mvalue) {
If ($_mindex / 2 <> ceil ($_mindex / 2)) {
$_masc = ord($_mvalue) - 31;
$_masc = $_masc + (ceil($_count * $_IV / 3) + $_IV);
$_count++;
if ($_count > 12)
$_count = 0;
$_encoded .= $_array[$_masc];
} else {
// No need to get around str_rot13 bug here since $_mvalue is
// not being referenced after this point & will get overriden.
$_encoded .= str_rot13($_mvalue);
}
}
return $_encoded;
}
// Encode function ends here
// Decode function starts here
function decode($_text, $_IV = 3, $_ENCRYPT_KEY = "z1Mc6KRxA7Nw90dGjY5qLXhtrPgJOfeCaUmHvQT3yW8nDsI2VkEpiS4blFoBuZ")
{
$_count = 0;
if (is_numeric($_IV)) {
$_IV = intval($_IV);
if ($_IV < 1)
$_IV = 1;
else
if ($_IV > 500)
$_IV = 42;
} else {
$_IV = 3;
}
$_arr1 = stringSplit($_ENCRYPT_KEY);
$_arr2 = $_arr1;
foreach ($_arr1 as $_i1 => $_v1) {
foreach ($_arr2 as $_i2 => $_v2) {
$_counter = ($_i2 + 1) + ($_i1 * strlen($_ENCRYPT_KEY));
$_array[$_counter] = $_v1 . $_v2;
if ($_v1 == $_v2)
$_array[$_counter] = $_v1 . '_';
}
}
$_array = array_flip($_array);
$_msgarr = stringSplit($_text, 3);
$_decoded = '';
foreach ($_msgarr as $_mvalue) {
// $_tmp_hold used to get around a possible PHP bug in versions
// earlier than 4.3.0. The variable passed in function might change.
$_tmp_hold = $_mvalue;
$_decoded .= str_rot13($_tmp_hold{0});
$_ivalue = $_array[substr($_mvalue, 1, 2)];
$_ivalue = $_ivalue - (ceil($_count * $_IV / 3) + $_IV);
$_count++;
if ($_count > 12)
$_count = 0;
$_masc = chr($_ivalue + 31);
$_decoded .= $_masc;
}
return trim($_decoded);
}
// Decode function ends here
?>


