The encrypt() and decrypt() functions need to have a key check. If key is empty, then return no encryption.
function encrypt($value) {
$output = '';
if (!$this->key) { return $value; }
for ($i = 0; $i < strlen($value); $i++) {
$char = substr($value, $i, 1);
$keychar = substr($this->key, ($i % strlen($this->key)) - 1, 1);
$char = chr(ord($char) + ord($keychar));
$output .= $char;
}
return base64_encode($output);
}
function decrypt($value) {
$output = '';
if (!$this->key) { return $value; }
$value = base64_decode($value);
for ($i = 0; $i < strlen($value); $i++) {
$char = substr($value, $i, 1);
$keychar = substr($this->key, ($i % strlen($this->key)) - 1, 1);
$char = chr(ord($char) - ord($keychar));
$output .= $char;
}
return $output;
}