Anybody could build an Encoder in php there are several types chipers are the most simple to understand however they are easy to break and would not be recommended to be used saying that if you just trying to protect something from a simple user or you wish to learn how to build some security in that it makes it a little harder to identify you could look into cypers or modulating cypers for a bit of security.
Just recently i was talking to someone who wanted to understand the basic's so i built one based on binary value manipulation,
DO NOT USE THIS FOR ANYTHING MORE THAN PLAYING OR LEARNING A LITTLE
class binChar{
function __construct(){
$this->pats = array('0', '1', '00', '11', '000', '111', '0000', '1111', '00000', '11111');
}
function encrypt($str){
$str = str_replace(array("\r", "\n", "\t", " "), array('\r', '\n', '\t', '\s'), $str);
$strN = str_split($str);
$bin = "";
foreach($strN as $char){
$charC = decbin(ord($char));
$count = count((string)$charC);
while($count < 8){
$chars = "0".$charC;
$count++;
}
$bin .= $chars;
}
echo "Given \r\n ".$str." \r\n Binary\r\n".$bin."\r\n";
foreach($this->pats as $key => $pat){
$bin = str_replace($pat, $key, $bin);
}
return $bin;
}
function decrypt($bin){
foreach($this->pats as $key => $pat){
$bin = str_replace($key, $pat, $bin);
}
$str = "";
$chars = str_split($bin, 8);
foreach($chars as $char){
$str .= chr(bindec($char));
}
$str = str_replace(array('\r', '\n', '\t', '\s'), array("\r", "\n", "\t", " "), $str);
return $str;
}
}
$enc = new binChar();
$test = $enc->encrypt("Hello World");
echo "Encrypted\r\n".$test;
echo "\r\nDecrypted\r\n".$enc->decrypt($test);
I Repeat i would never recommend you used this for anything other than playing with and testing / learning how it works it's just a basic example of some obfuscation.
And i know using AES in php is not easy to understand and it's not a simple function call however using it your data will be secured far better.