<?php
if (!defined('NTLCMS')) die('<center><b>Restricted access</b></center>');			
class encryption {
public function xoft_encode($string, $key){
$result = '';
for ($i = 1; $i <= strlen($string); $i++){
$char = substr($string, $i - 1, 1);
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
$char = chr(ord($char) + ord($keychar));
$result .= $char;
} 
return self :: safe_encode($result);
}
public function xoft_decode($string, $key){
$string = self :: safe_decode($string);
$result = '';
for ($i = 1; $i <= strlen($string); $i++){
$char = substr($string, $i - 1, 1);
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
$char = chr(ord($char) - ord($keychar));
$result .= $char;
} 
return $result;
} 
public function safe_encode($string){
$data = base64_encode($string);
$data = str_replace(array('+', '/', '='), array('_', '-', ''), $data);
return $data;
} 
public function safe_decode($string){
$string = str_replace(array('_', '-'), array('+', '/'), $string);
$data = base64_decode($string);
return $data;
} 
}
$crypt = new encryption; 
?>